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/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 374 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 display_manager()->OnNativeDisplaysChanged(displays); | 385 display_manager()->OnNativeDisplaysChanged(displays); |
386 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 386 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
387 | 387 |
388 // and resume with different external display. | 388 // and resume with different external display. |
389 displays.push_back(native_display); | 389 displays.push_back(native_display); |
390 displays.push_back(gfx::Display(11, gfx::Rect(1, 1, 100, 100))); | 390 displays.push_back(gfx::Display(11, gfx::Rect(1, 1, 100, 100))); |
391 display_manager()->OnNativeDisplaysChanged(displays); | 391 display_manager()->OnNativeDisplaysChanged(displays); |
392 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); | 392 EXPECT_EQ(2U, display_manager()->GetNumDisplays()); |
393 } | 393 } |
394 | 394 |
| 395 TEST_F(DisplayManagerTest, TestNativeDisplaysChangedNoInternal) { |
| 396 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 397 |
| 398 // Don't change the display info if all displays are disconnected. |
| 399 std::vector<gfx::Display> displays; |
| 400 display_manager()->OnNativeDisplaysChanged(displays); |
| 401 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 402 |
| 403 // Connect another display which will become primary. |
| 404 const gfx::Display external_display(10, gfx::Rect(1, 1, 100, 100)); |
| 405 displays.push_back(external_display); |
| 406 display_manager()->OnNativeDisplaysChanged(displays); |
| 407 EXPECT_EQ(1U, display_manager()->GetNumDisplays()); |
| 408 EXPECT_EQ("1,1 100x100", |
| 409 FindDisplayForId(10).bounds_in_pixel().ToString()); |
| 410 } |
| 411 |
395 TEST_F(DisplayManagerTest, EnsurePointerInDisplays) { | 412 TEST_F(DisplayManagerTest, EnsurePointerInDisplays) { |
396 UpdateDisplay("200x200,300x300"); | 413 UpdateDisplay("200x200,300x300"); |
397 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); | 414 Shell::RootWindowList root_windows = Shell::GetAllRootWindows(); |
398 | 415 |
399 aura::Env* env = aura::Env::GetInstance(); | 416 aura::Env* env = aura::Env::GetInstance(); |
400 | 417 |
401 // Set the initial position. | 418 // Set the initial position. |
402 root_windows[0]->MoveCursorTo(gfx::Point(350, 150)); | 419 root_windows[0]->MoveCursorTo(gfx::Point(350, 150)); |
403 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); | 420 EXPECT_EQ("350,150", env->last_mouse_location().ToString()); |
404 | 421 |
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
490 // OnNativeDisplaysChanged may change the display bounds. Here makes sure | 507 // OnNativeDisplaysChanged may change the display bounds. Here makes sure |
491 // nothing changed if the exactly same displays are specified. | 508 // nothing changed if the exactly same displays are specified. |
492 display_manager()->OnNativeDisplaysChanged(displays); | 509 display_manager()->OnNativeDisplaysChanged(displays); |
493 EXPECT_EQ("-500,0 500x500", | 510 EXPECT_EQ("-500,0 500x500", |
494 FindDisplayForId(internal_display_id).bounds().ToString()); | 511 FindDisplayForId(internal_display_id).bounds().ToString()); |
495 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); | 512 EXPECT_EQ("0,0 100x100", FindDisplayForId(10).bounds().ToString()); |
496 } | 513 } |
497 | 514 |
498 } // namespace internal | 515 } // namespace internal |
499 } // namespace ash | 516 } // namespace ash |
OLD | NEW |