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/display/screen_position_controller.h" | 5 #include "ash/display/screen_position_controller.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/shell.h" | 8 #include "ash/shell.h" |
9 #include "ash/test/ash_test_base.h" | 9 #include "ash/test/ash_test_base.h" |
10 #include "ui/aura/env.h" | 10 #include "ui/aura/env.h" |
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
82 UpdateDisplay("100+100-200x200,100+500-200x200"); | 82 UpdateDisplay("100+100-200x200,100+500-200x200"); |
83 | 83 |
84 Shell::RootWindowList root_windows = | 84 Shell::RootWindowList root_windows = |
85 Shell::GetInstance()->GetAllRootWindows(); | 85 Shell::GetInstance()->GetAllRootWindows(); |
86 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); | 86 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); |
87 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); | 87 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); |
88 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); | 88 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); |
89 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); | 89 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); |
90 | 90 |
91 const gfx::Point window_pos(100, 100); | 91 const gfx::Point window_pos(100, 100); |
92 window_->SetBoundsInScreen(gfx::Rect(window_pos, gfx::Size(100, 100)), | 92 window_->SetBoundsInScreen( |
93 gfx::Screen::GetDisplayNearestPoint(window_pos)); | 93 gfx::Rect(window_pos, gfx::Size(100, 100)), |
| 94 Shell::GetScreen()->GetDisplayNearestPoint(window_pos)); |
94 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); | 95 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); |
95 // The point is on the primary root window. | 96 // The point is on the primary root window. |
96 EXPECT_EQ("150,150", ConvertNativePointToScreen(50, 50)); | 97 EXPECT_EQ("150,150", ConvertNativePointToScreen(50, 50)); |
97 // The point is out of the all root windows. | 98 // The point is out of the all root windows. |
98 EXPECT_EQ("350,350", ConvertNativePointToScreen(250, 250)); | 99 EXPECT_EQ("350,350", ConvertNativePointToScreen(250, 250)); |
99 // The point is on the secondary display. | 100 // The point is on the secondary display. |
100 EXPECT_EQ("350,100", ConvertNativePointToScreen(50, 400)); | 101 EXPECT_EQ("350,100", ConvertNativePointToScreen(50, 400)); |
101 | 102 |
102 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); | 103 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); |
103 // The point is on the primary root window. | 104 // The point is on the primary root window. |
(...skipping 15 matching lines...) Expand all Loading... |
119 // The point is on the primary root window. | 120 // The point is on the primary root window. |
120 EXPECT_EQ("150,150", ConvertNativePointToScreen(50, 50)); | 121 EXPECT_EQ("150,150", ConvertNativePointToScreen(50, 50)); |
121 // The point is out of the all root windows. | 122 // The point is out of the all root windows. |
122 EXPECT_EQ("350,350", ConvertNativePointToScreen(250, 250)); | 123 EXPECT_EQ("350,350", ConvertNativePointToScreen(250, 250)); |
123 // The point is on the secondary display. | 124 // The point is on the secondary display. |
124 EXPECT_EQ("150,-100", ConvertNativePointToScreen(50, 400)); | 125 EXPECT_EQ("150,-100", ConvertNativePointToScreen(50, 400)); |
125 | 126 |
126 | 127 |
127 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); | 128 SetSecondaryDisplayLayout(DisplayLayout::RIGHT); |
128 const gfx::Point window_pos2(300, 100); | 129 const gfx::Point window_pos2(300, 100); |
129 window_->SetBoundsInScreen(gfx::Rect(window_pos2, gfx::Size(100, 100)), | 130 window_->SetBoundsInScreen( |
130 gfx::Screen::GetDisplayNearestPoint(window_pos2)); | 131 gfx::Rect(window_pos2, gfx::Size(100, 100)), |
| 132 Shell::GetScreen()->GetDisplayNearestPoint(window_pos2)); |
131 // The point is on the secondary display. | 133 // The point is on the secondary display. |
132 EXPECT_EQ("350,150", ConvertNativePointToScreen(50, 50)); | 134 EXPECT_EQ("350,150", ConvertNativePointToScreen(50, 50)); |
133 // The point is out of the all root windows. | 135 // The point is out of the all root windows. |
134 EXPECT_EQ("550,350", ConvertNativePointToScreen(250, 250)); | 136 EXPECT_EQ("550,350", ConvertNativePointToScreen(250, 250)); |
135 // The point is on the primary root window. | 137 // The point is on the primary root window. |
136 EXPECT_EQ("150,100", ConvertNativePointToScreen(50, -400)); | 138 EXPECT_EQ("150,100", ConvertNativePointToScreen(50, -400)); |
137 | 139 |
138 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); | 140 SetSecondaryDisplayLayout(DisplayLayout::BOTTOM); |
139 // The point is on the secondary display. | 141 // The point is on the secondary display. |
140 EXPECT_EQ("150,350", ConvertNativePointToScreen(50, 50)); | 142 EXPECT_EQ("150,350", ConvertNativePointToScreen(50, 50)); |
(...skipping 23 matching lines...) Expand all Loading... |
164 UpdateDisplay("100+100-200x200*2,100+500-200x200"); | 166 UpdateDisplay("100+100-200x200*2,100+500-200x200"); |
165 | 167 |
166 Shell::RootWindowList root_windows = | 168 Shell::RootWindowList root_windows = |
167 Shell::GetInstance()->GetAllRootWindows(); | 169 Shell::GetInstance()->GetAllRootWindows(); |
168 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); | 170 EXPECT_EQ("100,100", root_windows[0]->GetHostOrigin().ToString()); |
169 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); | 171 EXPECT_EQ("200x200", root_windows[0]->GetHostSize().ToString()); |
170 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); | 172 EXPECT_EQ("100,500", root_windows[1]->GetHostOrigin().ToString()); |
171 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); | 173 EXPECT_EQ("200x200", root_windows[1]->GetHostSize().ToString()); |
172 | 174 |
173 ash::DisplayController* display_controller = | 175 ash::DisplayController* display_controller = |
174 ash::Shell::GetInstance()->display_controller(); | 176 Shell::GetInstance()->display_controller(); |
175 // Put |window_| to the primary 2x display. | 177 // Put |window_| to the primary 2x display. |
176 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), | 178 window_->SetBoundsInScreen(gfx::Rect(20, 20, 50, 50), |
177 display_controller->GetPrimaryDisplay()); | 179 display_controller->GetPrimaryDisplay()); |
178 // (30, 30) means the native coordinate, so the point is still on the primary | 180 // (30, 30) means the native coordinate, so the point is still on the primary |
179 // root window. Since it's 2x, the specified native point was halved. | 181 // root window. Since it's 2x, the specified native point was halved. |
180 EXPECT_EQ("35,35", ConvertNativePointToScreen(30, 30)); | 182 EXPECT_EQ("35,35", ConvertNativePointToScreen(30, 30)); |
181 // Similar to above but the point is out of the all root windows. | 183 // Similar to above but the point is out of the all root windows. |
182 EXPECT_EQ("220,220", ConvertNativePointToScreen(400, 400)); | 184 EXPECT_EQ("220,220", ConvertNativePointToScreen(400, 400)); |
183 // Similar to above but the point is on the secondary display. | 185 // Similar to above but the point is on the secondary display. |
184 EXPECT_EQ("120,35", ConvertNativePointToScreen(200, 30)); | 186 EXPECT_EQ("120,35", ConvertNativePointToScreen(200, 30)); |
185 // At the edge but still in the primary display. Remaining of the primary | 187 // At the edge but still in the primary display. Remaining of the primary |
186 // display is (50, 50) but adding ~100 since it's 2x-display. | 188 // display is (50, 50) but adding ~100 since it's 2x-display. |
187 EXPECT_EQ("99,99", ConvertNativePointToScreen(159, 159)); | 189 EXPECT_EQ("99,99", ConvertNativePointToScreen(159, 159)); |
188 // At the edge of the secondary display. | 190 // At the edge of the secondary display. |
189 EXPECT_EQ("100,100", ConvertNativePointToScreen(160, 160)); | 191 EXPECT_EQ("100,100", ConvertNativePointToScreen(160, 160)); |
190 } | 192 } |
191 | 193 |
192 } // namespace test | 194 } // namespace test |
193 } // namespace ash | 195 } // namespace ash |
OLD | NEW |