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/display_controller.h" | 5 #include "ash/display/display_controller.h" |
6 | 6 |
7 #include "ash/launcher/launcher.h" | 7 #include "ash/launcher/launcher.h" |
8 #include "ash/screen_ash.h" | 8 #include "ash/screen_ash.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/test/ash_test_base.h" | 10 #include "ash/test/ash_test_base.h" |
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
201 EXPECT_NE(primary_display.id(), secondary_display.id()); | 201 EXPECT_NE(primary_display.id(), secondary_display.id()); |
202 aura::RootWindow* primary_root = | 202 aura::RootWindow* primary_root = |
203 display_controller->GetRootWindowForDisplayId(primary_display.id()); | 203 display_controller->GetRootWindowForDisplayId(primary_display.id()); |
204 aura::RootWindow* secondary_root = | 204 aura::RootWindow* secondary_root = |
205 display_controller->GetRootWindowForDisplayId(secondary_display.id()); | 205 display_controller->GetRootWindowForDisplayId(secondary_display.id()); |
206 EXPECT_NE(primary_root, secondary_root); | 206 EXPECT_NE(primary_root, secondary_root); |
207 aura::Window* launcher_window = | 207 aura::Window* launcher_window = |
208 Shell::GetInstance()->launcher()->widget()->GetNativeView(); | 208 Shell::GetInstance()->launcher()->widget()->GetNativeView(); |
209 EXPECT_TRUE(primary_root->Contains(launcher_window)); | 209 EXPECT_TRUE(primary_root->Contains(launcher_window)); |
210 EXPECT_FALSE(secondary_root->Contains(launcher_window)); | 210 EXPECT_FALSE(secondary_root->Contains(launcher_window)); |
| 211 EXPECT_EQ(primary_display.id(), |
| 212 gfx::Screen::GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); |
| 213 EXPECT_EQ(primary_display.id(), |
| 214 gfx::Screen::GetDisplayNearestWindow(NULL).id()); |
211 | 215 |
212 // Switch primary and secondary | 216 // Switch primary and secondary |
213 display_controller->SetPrimaryDisplay(secondary_display); | 217 display_controller->SetPrimaryDisplay(secondary_display); |
214 EXPECT_EQ(secondary_display.id(), gfx::Screen::GetPrimaryDisplay().id()); | 218 EXPECT_EQ(secondary_display.id(), gfx::Screen::GetPrimaryDisplay().id()); |
215 EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); | 219 EXPECT_EQ(primary_display.id(), ScreenAsh::GetSecondaryDisplay().id()); |
| 220 EXPECT_EQ(secondary_display.id(), |
| 221 gfx::Screen::GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); |
| 222 EXPECT_EQ(secondary_display.id(), |
| 223 gfx::Screen::GetDisplayNearestWindow(NULL).id()); |
216 | 224 |
217 EXPECT_EQ( | 225 EXPECT_EQ( |
218 primary_root, | 226 primary_root, |
219 display_controller->GetRootWindowForDisplayId(secondary_display.id())); | 227 display_controller->GetRootWindowForDisplayId(secondary_display.id())); |
220 EXPECT_EQ( | 228 EXPECT_EQ( |
221 secondary_root, | 229 secondary_root, |
222 display_controller->GetRootWindowForDisplayId(primary_display.id())); | 230 display_controller->GetRootWindowForDisplayId(primary_display.id())); |
223 EXPECT_TRUE(primary_root->Contains(launcher_window)); | 231 EXPECT_TRUE(primary_root->Contains(launcher_window)); |
224 EXPECT_FALSE(secondary_root->Contains(launcher_window)); | 232 EXPECT_FALSE(secondary_root->Contains(launcher_window)); |
225 | 233 |
226 const DisplayLayout& inverted_layout = | 234 const DisplayLayout& inverted_layout = |
227 display_controller->GetLayoutForDisplay(primary_display); | 235 display_controller->GetLayoutForDisplay(primary_display); |
228 | 236 |
229 EXPECT_EQ("left, -50", inverted_layout.ToString()); | 237 EXPECT_EQ("left, -50", inverted_layout.ToString()); |
230 | 238 |
231 aura::WindowTracker tracker; | 239 aura::WindowTracker tracker; |
232 tracker.Add(primary_root); | 240 tracker.Add(primary_root); |
233 tracker.Add(secondary_root); | 241 tracker.Add(secondary_root); |
234 | 242 |
235 // Deleting 2nd display should move the primary to original primary display. | 243 // Deleting 2nd display should move the primary to original primary display. |
236 UpdateDisplay("200x200"); | 244 UpdateDisplay("200x200"); |
237 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. | 245 RunAllPendingInMessageLoop(); // RootWindow is deleted in a posted task. |
238 EXPECT_EQ(1, gfx::Screen::GetNumDisplays()); | 246 EXPECT_EQ(1, gfx::Screen::GetNumDisplays()); |
239 EXPECT_EQ(primary_display.id(), gfx::Screen::GetPrimaryDisplay().id()); | 247 EXPECT_EQ(primary_display.id(), gfx::Screen::GetPrimaryDisplay().id()); |
| 248 EXPECT_EQ(primary_display.id(), |
| 249 gfx::Screen::GetDisplayNearestPoint(gfx::Point(-100, -100)).id()); |
| 250 EXPECT_EQ(primary_display.id(), |
| 251 gfx::Screen::GetDisplayNearestWindow(NULL).id()); |
240 EXPECT_TRUE(tracker.Contains(primary_root)); | 252 EXPECT_TRUE(tracker.Contains(primary_root)); |
241 EXPECT_FALSE(tracker.Contains(secondary_root)); | 253 EXPECT_FALSE(tracker.Contains(secondary_root)); |
242 EXPECT_TRUE(primary_root->Contains(launcher_window)); | 254 EXPECT_TRUE(primary_root->Contains(launcher_window)); |
243 } | 255 } |
244 | 256 |
245 TEST_F(DisplayControllerTest, MAYBE_UpdateDisplayWithHostOrigin) { | 257 TEST_F(DisplayControllerTest, MAYBE_UpdateDisplayWithHostOrigin) { |
246 UpdateDisplay("100x200,300x400"); | 258 UpdateDisplay("100x200,300x400"); |
247 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); | 259 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); |
248 Shell::RootWindowList root_windows = | 260 Shell::RootWindowList root_windows = |
249 Shell::GetInstance()->GetAllRootWindows(); | 261 Shell::GetInstance()->GetAllRootWindows(); |
(...skipping 21 matching lines...) Expand all Loading... |
271 UpdateDisplay("100+200-100x200,300+500-200x300"); | 283 UpdateDisplay("100+200-100x200,300+500-200x300"); |
272 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); | 284 ASSERT_EQ(2, gfx::Screen::GetNumDisplays()); |
273 EXPECT_EQ("100,200", root_windows[0]->GetHostOrigin().ToString()); | 285 EXPECT_EQ("100,200", root_windows[0]->GetHostOrigin().ToString()); |
274 EXPECT_EQ("100x200", root_windows[0]->GetHostSize().ToString()); | 286 EXPECT_EQ("100x200", root_windows[0]->GetHostSize().ToString()); |
275 EXPECT_EQ("300,500", root_windows[1]->GetHostOrigin().ToString()); | 287 EXPECT_EQ("300,500", root_windows[1]->GetHostOrigin().ToString()); |
276 EXPECT_EQ("200x300", root_windows[1]->GetHostSize().ToString()); | 288 EXPECT_EQ("200x300", root_windows[1]->GetHostSize().ToString()); |
277 } | 289 } |
278 | 290 |
279 } // namespace test | 291 } // namespace test |
280 } // namespace ash | 292 } // namespace ash |
OLD | NEW |