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_manager.h" | 5 #include "ash/display/display_manager.h" |
6 | 6 |
7 #include "ash/display/display_controller.h" | 7 #include "ash/display/display_controller.h" |
8 #include "ash/display/display_layout_store.h" | 8 #include "ash/display/display_layout_store.h" |
9 #include "ash/screen_ash.h" | 9 #include "ash/screen_util.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
13 #include "ash/test/mirror_window_test_api.h" | 13 #include "ash/test/mirror_window_test_api.h" |
14 #include "base/format_macros.h" | 14 #include "base/format_macros.h" |
15 #include "base/strings/string_number_conversions.h" | 15 #include "base/strings/string_number_conversions.h" |
16 #include "base/strings/stringprintf.h" | 16 #include "base/strings/stringprintf.h" |
17 #include "ui/aura/env.h" | 17 #include "ui/aura/env.h" |
18 #include "ui/aura/root_window.h" | 18 #include "ui/aura/root_window.h" |
19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
20 #include "ui/aura/window_observer.h" | 20 #include "ui/aura/window_observer.h" |
21 #include "ui/gfx/display_observer.h" | 21 #include "ui/gfx/display_observer.h" |
22 #include "ui/gfx/display.h" | 22 #include "ui/gfx/display.h" |
| 23 #include "ui/gfx/screen.h" |
| 24 #include "ui/gfx/screen_type_delegate.h" |
23 | 25 |
24 namespace ash { | 26 namespace ash { |
25 namespace internal { | 27 namespace internal { |
26 | 28 |
27 using std::vector; | 29 using std::vector; |
28 using std::string; | 30 using std::string; |
29 | 31 |
30 using base::StringPrintf; | 32 using base::StringPrintf; |
31 | 33 |
32 namespace { | 34 namespace { |
(...skipping 233 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
266 EXPECT_EQ("0,0 500x500", | 268 EXPECT_EQ("0,0 500x500", |
267 GetDisplayInfoAt(0).bounds_in_native().ToString()); | 269 GetDisplayInfoAt(0).bounds_in_native().ToString()); |
268 DisplayInfo updated_display_info2 = GetDisplayInfoAt(1); | 270 DisplayInfo updated_display_info2 = GetDisplayInfoAt(1); |
269 EXPECT_EQ("0,501 400x400", | 271 EXPECT_EQ("0,501 400x400", |
270 updated_display_info2.bounds_in_native().ToString()); | 272 updated_display_info2.bounds_in_native().ToString()); |
271 EXPECT_EQ("378x376", | 273 EXPECT_EQ("378x376", |
272 updated_display_info2.size_in_pixel().ToString()); | 274 updated_display_info2.size_in_pixel().ToString()); |
273 EXPECT_EQ("13,12,11,10", | 275 EXPECT_EQ("13,12,11,10", |
274 updated_display_info2.overscan_insets_in_dip().ToString()); | 276 updated_display_info2.overscan_insets_in_dip().ToString()); |
275 EXPECT_EQ("500,0 378x376", | 277 EXPECT_EQ("500,0 378x376", |
276 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 278 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
277 | 279 |
278 // Make sure that SetOverscanInsets() is idempotent. | 280 // Make sure that SetOverscanInsets() is idempotent. |
279 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); | 281 display_manager()->SetOverscanInsets(display_info1.id(), gfx::Insets()); |
280 display_manager()->SetOverscanInsets( | 282 display_manager()->SetOverscanInsets( |
281 display_info2.id(), gfx::Insets(13, 12, 11, 10)); | 283 display_info2.id(), gfx::Insets(13, 12, 11, 10)); |
282 EXPECT_EQ("0,0 500x500", | 284 EXPECT_EQ("0,0 500x500", |
283 GetDisplayInfoAt(0).bounds_in_native().ToString()); | 285 GetDisplayInfoAt(0).bounds_in_native().ToString()); |
284 updated_display_info2 = GetDisplayInfoAt(1); | 286 updated_display_info2 = GetDisplayInfoAt(1); |
285 EXPECT_EQ("0,501 400x400", | 287 EXPECT_EQ("0,501 400x400", |
286 updated_display_info2.bounds_in_native().ToString()); | 288 updated_display_info2.bounds_in_native().ToString()); |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
333 updated_display_info2.bounds_in_native().ToString()); | 335 updated_display_info2.bounds_in_native().ToString()); |
334 EXPECT_EQ("376x380", | 336 EXPECT_EQ("376x380", |
335 updated_display_info2.size_in_pixel().ToString()); | 337 updated_display_info2.size_in_pixel().ToString()); |
336 EXPECT_EQ("4,5,6,7", | 338 EXPECT_EQ("4,5,6,7", |
337 updated_display_info2.overscan_insets_in_dip().ToString()); | 339 updated_display_info2.overscan_insets_in_dip().ToString()); |
338 EXPECT_EQ("8,10,12,14", | 340 EXPECT_EQ("8,10,12,14", |
339 updated_display_info2.GetOverscanInsetsInPixel().ToString()); | 341 updated_display_info2.GetOverscanInsetsInPixel().ToString()); |
340 | 342 |
341 // Make sure switching primary display applies the overscan offset only once. | 343 // Make sure switching primary display applies the overscan offset only once. |
342 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( | 344 ash::Shell::GetInstance()->display_controller()->SetPrimaryDisplay( |
343 ScreenAsh::GetSecondaryDisplay()); | 345 ScreenUtil::GetSecondaryDisplay()); |
344 EXPECT_EQ("-500,0 500x500", | 346 EXPECT_EQ("-500,0 500x500", |
345 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 347 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
346 EXPECT_EQ("0,0 500x500", | 348 EXPECT_EQ("0,0 500x500", |
347 GetDisplayInfo(ScreenAsh::GetSecondaryDisplay()). | 349 GetDisplayInfo(ScreenUtil::GetSecondaryDisplay()). |
348 bounds_in_native().ToString()); | 350 bounds_in_native().ToString()); |
349 EXPECT_EQ("0,501 400x400", | 351 EXPECT_EQ("0,501 400x400", |
350 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). | 352 GetDisplayInfo(Shell::GetScreen()->GetPrimaryDisplay()). |
351 bounds_in_native().ToString()); | 353 bounds_in_native().ToString()); |
352 EXPECT_EQ("0,0 188x190", | 354 EXPECT_EQ("0,0 188x190", |
353 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); | 355 Shell::GetScreen()->GetPrimaryDisplay().bounds().ToString()); |
354 } | 356 } |
355 | 357 |
356 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { | 358 TEST_F(DisplayManagerTest, ZeroOverscanInsets) { |
357 if (!SupportsMultipleDisplays()) | 359 if (!SupportsMultipleDisplays()) |
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 DisplayLayoutStore* layout_store = | 650 DisplayLayoutStore* layout_store = |
649 Shell::GetInstance()->display_manager()->layout_store(); | 651 Shell::GetInstance()->display_manager()->layout_store(); |
650 DisplayLayout layout = layout_store->default_display_layout(); | 652 DisplayLayout layout = layout_store->default_display_layout(); |
651 layout.position = DisplayLayout::LEFT; | 653 layout.position = DisplayLayout::LEFT; |
652 layout_store->SetDefaultDisplayLayout(layout); | 654 layout_store->SetDefaultDisplayLayout(layout); |
653 | 655 |
654 UpdateDisplay("200x200,300x300"); | 656 UpdateDisplay("200x200,300x300"); |
655 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); | 657 aura::Window::Windows root_windows = Shell::GetAllRootWindows(); |
656 | 658 |
657 EXPECT_EQ("-300,0 300x300", | 659 EXPECT_EQ("-300,0 300x300", |
658 ScreenAsh::GetSecondaryDisplay().bounds().ToString()); | 660 ScreenUtil::GetSecondaryDisplay().bounds().ToString()); |
659 | 661 |
660 aura::Env* env = aura::Env::GetInstance(); | 662 aura::Env* env = aura::Env::GetInstance(); |
661 | 663 |
662 // Set the initial position. | 664 // Set the initial position. |
663 root_windows[0]->MoveCursorTo(gfx::Point(-150, 250)); | 665 root_windows[0]->MoveCursorTo(gfx::Point(-150, 250)); |
664 EXPECT_EQ("-150,250", env->last_mouse_location().ToString()); | 666 EXPECT_EQ("-150,250", env->last_mouse_location().ToString()); |
665 | 667 |
666 // A mouse pointer will stay in 2nd display. | 668 // A mouse pointer will stay in 2nd display. |
667 UpdateDisplay("300x300,200x300"); | 669 UpdateDisplay("300x300,200x300"); |
668 EXPECT_EQ("-50,150", env->last_mouse_location().ToString()); | 670 EXPECT_EQ("-50,150", env->last_mouse_location().ToString()); |
(...skipping 505 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 EXPECT_EQ("300x400", dispatcher1->host()->GetBounds().size().ToString()); | 1176 EXPECT_EQ("300x400", dispatcher1->host()->GetBounds().size().ToString()); |
1175 | 1177 |
1176 UpdateDisplay("100+200-100x200,300+500-200x300"); | 1178 UpdateDisplay("100+200-100x200,300+500-200x300"); |
1177 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); | 1179 ASSERT_EQ(2, Shell::GetScreen()->GetNumDisplays()); |
1178 EXPECT_EQ("100,200", dispatcher0->host()->GetBounds().origin().ToString()); | 1180 EXPECT_EQ("100,200", dispatcher0->host()->GetBounds().origin().ToString()); |
1179 EXPECT_EQ("100x200", dispatcher0->host()->GetBounds().size().ToString()); | 1181 EXPECT_EQ("100x200", dispatcher0->host()->GetBounds().size().ToString()); |
1180 EXPECT_EQ("300,500", dispatcher1->host()->GetBounds().origin().ToString()); | 1182 EXPECT_EQ("300,500", dispatcher1->host()->GetBounds().origin().ToString()); |
1181 EXPECT_EQ("200x300", dispatcher1->host()->GetBounds().size().ToString()); | 1183 EXPECT_EQ("200x300", dispatcher1->host()->GetBounds().size().ToString()); |
1182 } | 1184 } |
1183 | 1185 |
| 1186 |
| 1187 class ScreenShutdownTest : public test::AshTestBase { |
| 1188 public: |
| 1189 ScreenShutdownTest() { |
| 1190 } |
| 1191 virtual ~ScreenShutdownTest() {} |
| 1192 |
| 1193 virtual void TearDown() OVERRIDE { |
| 1194 AshTestBase::TearDown(); |
| 1195 gfx::Screen* screen = |
| 1196 gfx::Screen::GetScreenByType(gfx::SCREEN_TYPE_ALTERNATE); |
| 1197 EXPECT_EQ(2, screen->GetNumDisplays()); |
| 1198 EXPECT_EQ("500x300", screen->GetPrimaryDisplay().size().ToString()); |
| 1199 std::vector<gfx::Display> all = screen->GetAllDisplays(); |
| 1200 EXPECT_EQ("500x300", all[0].size().ToString()); |
| 1201 EXPECT_EQ("800x400", all[1].size().ToString()); |
| 1202 } |
| 1203 |
| 1204 private: |
| 1205 DISALLOW_COPY_AND_ASSIGN(ScreenShutdownTest); |
| 1206 }; |
| 1207 |
| 1208 TEST_F(DisplayManagerTest, ScreenAfterShutdown) { |
| 1209 UpdateDisplay("500x300,800x400"); |
| 1210 } |
| 1211 |
1184 } // namespace internal | 1212 } // namespace internal |
1185 } // namespace ash | 1213 } // namespace ash |
OLD | NEW |