OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "ash/test/ash_test_base.h" | 5 #include "ash/test/ash_test_base.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
| 10 #include "ash/display/display_controller.h" |
10 #include "ash/shell.h" | 11 #include "ash/shell.h" |
11 #include "ash/test/test_shell_delegate.h" | 12 #include "ash/test/test_shell_delegate.h" |
12 #include "base/run_loop.h" | 13 #include "base/run_loop.h" |
13 #include "base/string_split.h" | 14 #include "base/string_split.h" |
14 #include "content/public/test/web_contents_tester.h" | 15 #include "content/public/test/web_contents_tester.h" |
15 #include "ui/aura/env.h" | 16 #include "ui/aura/env.h" |
16 #include "ui/aura/display_manager.h" | 17 #include "ui/aura/display_manager.h" |
17 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
18 #include "ui/base/ime/text_input_test_support.h" | 19 #include "ui/base/ime/text_input_test_support.h" |
19 #include "ui/compositor/layer_animator.h" | 20 #include "ui/compositor/layer_animator.h" |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 std::vector<gfx::Display> displays; | 81 std::vector<gfx::Display> displays; |
81 displays.push_back(display); | 82 displays.push_back(display); |
82 aura::Env::GetInstance()->display_manager()->OnNativeDisplaysChanged( | 83 aura::Env::GetInstance()->display_manager()->OnNativeDisplaysChanged( |
83 displays); | 84 displays); |
84 } | 85 } |
85 | 86 |
86 void AshTestBase::UpdateDisplay(const std::string& display_specs) { | 87 void AshTestBase::UpdateDisplay(const std::string& display_specs) { |
87 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); | 88 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); |
88 aura::Env::GetInstance()->display_manager()-> | 89 aura::Env::GetInstance()->display_manager()-> |
89 OnNativeDisplaysChanged(displays); | 90 OnNativeDisplaysChanged(displays); |
| 91 |
| 92 // On non-testing environment, when a secondary display is connected, a new |
| 93 // native (i.e. X) window for the display is always created below the previous |
| 94 // one for GPU performance reasons. Try to emulate the behavior. |
| 95 if (internal::DisplayController::IsExtendedDesktopEnabled()) { |
| 96 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
| 97 DCHECK_EQ(displays.size(), root_windows.size()); |
| 98 size_t next_y = 0; |
| 99 for (size_t i = 0; i < root_windows.size(); ++i) { |
| 100 const gfx::Size size = root_windows[i]->GetHostSize(); |
| 101 root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size)); |
| 102 next_y += size.height(); |
| 103 } |
| 104 } |
90 } | 105 } |
91 | 106 |
92 void AshTestBase::RunAllPendingInMessageLoop() { | 107 void AshTestBase::RunAllPendingInMessageLoop() { |
93 #if !defined(OS_MACOSX) | 108 #if !defined(OS_MACOSX) |
94 DCHECK(MessageLoopForUI::current() == &message_loop_); | 109 DCHECK(MessageLoopForUI::current() == &message_loop_); |
95 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); | 110 base::RunLoop run_loop(aura::Env::GetInstance()->GetDispatcher()); |
96 run_loop.RunUntilIdle(); | 111 run_loop.RunUntilIdle(); |
97 #endif | 112 #endif |
98 } | 113 } |
99 | 114 |
100 } // namespace test | 115 } // namespace test |
101 } // namespace ash | 116 } // namespace ash |
OLD | NEW |