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/display_manager_test_api.h" | 5 #include "ash/test/display_manager_test_api.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/display/display_manager.h" | 9 #include "ash/display/display_manager.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
(...skipping 23 matching lines...) Expand all Loading... |
34 DisplayManagerTestApi::DisplayManagerTestApi( | 34 DisplayManagerTestApi::DisplayManagerTestApi( |
35 internal::DisplayManager* display_manager) | 35 internal::DisplayManager* display_manager) |
36 : display_manager_(display_manager) { | 36 : display_manager_(display_manager) { |
37 } | 37 } |
38 | 38 |
39 DisplayManagerTestApi::~DisplayManagerTestApi() {} | 39 DisplayManagerTestApi::~DisplayManagerTestApi() {} |
40 | 40 |
41 void DisplayManagerTestApi::UpdateDisplay( | 41 void DisplayManagerTestApi::UpdateDisplay( |
42 const std::string& display_specs) { | 42 const std::string& display_specs) { |
43 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); | 43 std::vector<gfx::Display> displays = CreateDisplaysFromString(display_specs); |
44 display_manager_->SetDisplayIdsForTest(&displays); | |
45 display_manager_->OnNativeDisplaysChanged(displays); | |
46 | |
47 bool is_host_origin_set = false; | 44 bool is_host_origin_set = false; |
48 for (size_t i = 0; i < displays.size(); ++i) { | 45 for (size_t i = 0; i < displays.size(); ++i) { |
49 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) { | 46 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) { |
50 is_host_origin_set = true; | 47 is_host_origin_set = true; |
51 break; | 48 break; |
52 } | 49 } |
53 } | 50 } |
54 | 51 |
55 // On non-testing environment, when a secondary display is connected, a new | 52 // On non-testing environment, when a secondary display is connected, a new |
56 // native (i.e. X) window for the display is always created below the | 53 // native (i.e. X) window for the display is always created below the |
57 // previous one for GPU performance reasons. Try to emulate the behavior | 54 // previous one for GPU performance reasons. Try to emulate the behavior |
58 // unless host origins are explicitly set. | 55 // unless host origins are explicitly set. |
59 if (!is_host_origin_set) { | 56 if (!is_host_origin_set) { |
60 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 57 // Sart from (1,1) so that windows won't overlap with native mouse cursor. |
61 int next_y = 0; | 58 // See |AshTestBase::SetUp()|. |
62 for (size_t i = 0; i < root_windows.size(); ++i) { | 59 int next_y = 1; |
63 const gfx::Size size = root_windows[i]->GetHostSize(); | 60 for (std::vector<gfx::Display>::iterator iter = displays.begin(); |
64 root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size)); | 61 iter != displays.end(); ++iter) { |
65 next_y += size.height(); | 62 gfx::Rect bounds(iter->GetSizeInPixel()); |
| 63 bounds.set_x(1); |
| 64 bounds.set_y(next_y); |
| 65 next_y += bounds.height(); |
| 66 iter->SetScaleAndBounds(iter->device_scale_factor(), bounds); |
66 } | 67 } |
67 } | 68 } |
| 69 |
| 70 display_manager_->SetDisplayIdsForTest(&displays); |
| 71 display_manager_->OnNativeDisplaysChanged(displays); |
68 } | 72 } |
69 | 73 |
70 } // namespace test | 74 } // namespace test |
71 } // namespace ash | 75 } // namespace ash |
OLD | NEW |