OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_orientation_controller_chromeos.h" | 5 #include "ash/display/screen_orientation_controller_chromeos.h" |
6 | 6 |
7 #include <memory> | 7 #include <memory> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "ash/common/ash_switches.h" | 10 #include "ash/common/ash_switches.h" |
(...skipping 404 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
415 } | 415 } |
416 | 416 |
417 // The ScreenLayoutObserver class that is responsible for adding/updating | 417 // The ScreenLayoutObserver class that is responsible for adding/updating |
418 // MessageCenter notifications is only added to the SystemTray on ChromeOS. | 418 // MessageCenter notifications is only added to the SystemTray on ChromeOS. |
419 // Tests that the screen rotation notifications are suppressed when | 419 // Tests that the screen rotation notifications are suppressed when |
420 // triggered by the accelerometer. | 420 // triggered by the accelerometer. |
421 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { | 421 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { |
422 EnableMaximizeMode(true); | 422 EnableMaximizeMode(true); |
423 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); | 423 test::TestSystemTrayDelegate* tray_delegate = GetSystemTrayDelegate(); |
424 tray_delegate->set_should_show_display_notification(true); | 424 tray_delegate->set_should_show_display_notification(true); |
425 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 425 test::DisplayManagerTestApi(display_manager()) |
| 426 .SetFirstDisplayAsInternalDisplay(); |
426 | 427 |
427 message_center::MessageCenter* message_center = | 428 message_center::MessageCenter* message_center = |
428 message_center::MessageCenter::Get(); | 429 message_center::MessageCenter::Get(); |
429 | 430 |
430 EXPECT_EQ(0u, message_center->NotificationCount()); | 431 EXPECT_EQ(0u, message_center->NotificationCount()); |
431 EXPECT_FALSE(message_center->HasPopupNotifications()); | 432 EXPECT_FALSE(message_center->HasPopupNotifications()); |
432 | 433 |
433 // Make sure notifications are still displayed when | 434 // Make sure notifications are still displayed when |
434 // adjusting the screen rotation directly when in maximize mode | 435 // adjusting the screen rotation directly when in maximize mode |
435 ASSERT_NE(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); | 436 ASSERT_NE(display::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
467 ASSERT_FALSE(message_center->HasPopupNotifications()); | 468 ASSERT_FALSE(message_center->HasPopupNotifications()); |
468 SetInternalDisplayRotation(display::Display::ROTATE_180); | 469 SetInternalDisplayRotation(display::Display::ROTATE_180); |
469 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); | 470 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
470 EXPECT_EQ(1u, message_center->NotificationCount()); | 471 EXPECT_EQ(1u, message_center->NotificationCount()); |
471 EXPECT_TRUE(message_center->HasPopupNotifications()); | 472 EXPECT_TRUE(message_center->HasPopupNotifications()); |
472 } | 473 } |
473 | 474 |
474 // Tests that if a user has set a display rotation that it is restored upon | 475 // Tests that if a user has set a display rotation that it is restored upon |
475 // exiting maximize mode. | 476 // exiting maximize mode. |
476 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) { | 477 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) { |
477 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 478 test::DisplayManagerTestApi(display_manager()) |
| 479 .SetFirstDisplayAsInternalDisplay(); |
478 | 480 |
479 SetInternalDisplayRotation(display::Display::ROTATE_90); | 481 SetInternalDisplayRotation(display::Display::ROTATE_90); |
480 EnableMaximizeMode(true); | 482 EnableMaximizeMode(true); |
481 | 483 |
482 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); | 484 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
483 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); | 485 EXPECT_EQ(display::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
484 | 486 |
485 EnableMaximizeMode(false); | 487 EnableMaximizeMode(false); |
486 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); | 488 EXPECT_EQ(display::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
487 } | 489 } |
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
593 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 595 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
594 | 596 |
595 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); | 597 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
596 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); | 598 EXPECT_EQ(display::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
597 } | 599 } |
598 | 600 |
599 // Tests that when MaximizeMode is triggered before the internal display is | 601 // Tests that when MaximizeMode is triggered before the internal display is |
600 // ready, that ScreenOrientationController still begins listening to events, | 602 // ready, that ScreenOrientationController still begins listening to events, |
601 // which require an internal display to be acted upon. | 603 // which require an internal display to be acted upon. |
602 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) { | 604 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) { |
603 test::DisplayManagerTestApi().SetFirstDisplayAsInternalDisplay(); | 605 test::DisplayManagerTestApi(display_manager()) |
| 606 .SetFirstDisplayAsInternalDisplay(); |
604 | 607 |
605 int64_t internal_display_id = display::Display::InternalDisplayId(); | 608 int64_t internal_display_id = display::Display::InternalDisplayId(); |
606 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); | 609 display::Display::SetInternalDisplayId(display::Display::kInvalidDisplayID); |
607 | 610 |
608 EnableMaximizeMode(true); | 611 EnableMaximizeMode(true); |
609 | 612 |
610 // Should not crash, even though there is no internal display. | 613 // Should not crash, even though there is no internal display. |
611 SetDisplayRotationById(internal_display_id, display::Display::ROTATE_180); | 614 SetDisplayRotationById(internal_display_id, display::Display::ROTATE_180); |
612 EXPECT_FALSE(RotationLocked()); | 615 EXPECT_FALSE(RotationLocked()); |
613 | 616 |
(...skipping 22 matching lines...) Expand all Loading... |
636 std::vector<display::ManagedDisplayInfo> display_info_list_two_active; | 639 std::vector<display::ManagedDisplayInfo> display_info_list_two_active; |
637 display_info_list_two_active.push_back(internal_display_info); | 640 display_info_list_two_active.push_back(internal_display_info); |
638 display_info_list_two_active.push_back(external_display_info); | 641 display_info_list_two_active.push_back(external_display_info); |
639 | 642 |
640 std::vector<display::ManagedDisplayInfo> display_info_list_one_active; | 643 std::vector<display::ManagedDisplayInfo> display_info_list_one_active; |
641 display_info_list_one_active.push_back(external_display_info); | 644 display_info_list_one_active.push_back(external_display_info); |
642 | 645 |
643 // The display::ManagedDisplayInfo list with two active displays needs to be | 646 // The display::ManagedDisplayInfo list with two active displays needs to be |
644 // added first so that the DisplayManager can track the | 647 // added first so that the DisplayManager can track the |
645 // |internal_display_info| as inactive instead of non-existent. | 648 // |internal_display_info| as inactive instead of non-existent. |
646 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 649 display_manager()->UpdateDisplaysWith(display_info_list_two_active); |
647 display_manager->UpdateDisplaysWith(display_info_list_two_active); | 650 display_manager()->UpdateDisplaysWith(display_info_list_one_active); |
648 display_manager->UpdateDisplaysWith(display_info_list_one_active); | |
649 | 651 |
650 test::ScopedSetInternalDisplayId set_internal(kInternalDisplayId); | 652 test::ScopedSetInternalDisplayId set_internal(display_manager(), |
| 653 kInternalDisplayId); |
651 | 654 |
652 ASSERT_NE( | 655 ASSERT_NE(kNewRotation, display_manager() |
653 kNewRotation, | 656 ->GetDisplayInfo(kInternalDisplayId) |
654 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); | 657 .GetActiveRotation()); |
655 | 658 |
656 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( | 659 Shell::GetInstance()->screen_orientation_controller()->SetDisplayRotation( |
657 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); | 660 kNewRotation, display::Display::ROTATION_SOURCE_ACTIVE); |
658 | 661 |
659 EXPECT_EQ( | 662 EXPECT_EQ(kNewRotation, display_manager() |
660 kNewRotation, | 663 ->GetDisplayInfo(kInternalDisplayId) |
661 display_manager->GetDisplayInfo(kInternalDisplayId).GetActiveRotation()); | 664 .GetActiveRotation()); |
662 } | 665 } |
663 | 666 |
664 } // namespace ash | 667 } // namespace ash |
OLD | NEW |