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 |
44 bool is_host_origin_set = false; | 47 bool is_host_origin_set = false; |
45 for (size_t i = 0; i < displays.size(); ++i) { | 48 for (size_t i = 0; i < displays.size(); ++i) { |
46 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) { | 49 if (displays[i].bounds_in_pixel().origin() != gfx::Point(0, 0)) { |
47 is_host_origin_set = true; | 50 is_host_origin_set = true; |
48 break; | 51 break; |
49 } | 52 } |
50 } | 53 } |
51 | 54 |
52 // On non-testing environment, when a secondary display is connected, a new | 55 // On non-testing environment, when a secondary display is connected, a new |
53 // native (i.e. X) window for the display is always created below the | 56 // native (i.e. X) window for the display is always created below the |
54 // previous one for GPU performance reasons. Try to emulate the behavior | 57 // previous one for GPU performance reasons. Try to emulate the behavior |
55 // unless host origins are explicitly set. | 58 // unless host origins are explicitly set. |
56 if (!is_host_origin_set) { | 59 if (!is_host_origin_set) { |
57 // Sart from (1,1) so that windows won't overlap with native mouse cursor. | 60 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
58 // See |AshTestBase::SetUp()|. | 61 int next_y = 0; |
59 int next_y = 1; | 62 for (size_t i = 0; i < root_windows.size(); ++i) { |
60 for (std::vector<gfx::Display>::iterator iter = displays.begin(); | 63 const gfx::Size size = root_windows[i]->GetHostSize(); |
61 iter != displays.end(); ++iter) { | 64 root_windows[i]->SetHostBounds(gfx::Rect(gfx::Point(0, next_y), size)); |
62 gfx::Rect bounds(iter->GetSizeInPixel()); | 65 next_y += size.height(); |
63 bounds.set_x(1); | |
64 bounds.set_y(next_y); | |
65 next_y += bounds.height(); | |
66 iter->SetScaleAndBounds(iter->device_scale_factor(), bounds); | |
67 } | 66 } |
68 } | 67 } |
69 | |
70 display_manager_->SetDisplayIdsForTest(&displays); | |
71 display_manager_->OnNativeDisplaysChanged(displays); | |
72 } | 68 } |
73 | 69 |
74 } // namespace test | 70 } // namespace test |
75 } // namespace ash | 71 } // namespace ash |
OLD | NEW |