Chromium Code Reviews| Index: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| diff --git a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| index ed9e80053455cfc2f457300475c85989b770a7eb..0110a37f7f2afbf2fa15cfa555456428cbfde0c8 100644 |
| --- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| +++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| @@ -9,9 +9,11 @@ |
| #include "ash/shell.h" |
| #include "ash/test/ash_test_base.h" |
| #include "ash/test/display_manager_test_api.h" |
| +#include "ash/test/test_system_tray_delegate.h" |
| #include "ui/aura/test/event_generator.h" |
|
jonross
2014/05/09 14:57:33
unused?
|
| #include "ui/events/event_handler.h" |
| #include "ui/gfx/vector3d_f.h" |
| +#include "ui/message_center/message_center.h" |
| namespace ash { |
| @@ -108,6 +110,11 @@ class MaximizeModeControllerTest : public test::AshTestBase { |
| gfx::Display::InternalDisplayId()).rotation(); |
| } |
| + void SetInternalDisplayRotation(gfx::Display::Rotation rotation) const { |
| + Shell::GetInstance()->display_manager()-> |
| + SetDisplayRotation(gfx::Display::InternalDisplayId(), rotation); |
| + } |
| + |
| private: |
| DISALLOW_COPY_AND_ASSIGN(MaximizeModeControllerTest); |
| }; |
| @@ -398,9 +405,7 @@ TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) { |
| // rotation becomes locked. |
| TEST_F(MaximizeModeControllerTest, |
| RotatedDisplayLocksRotationUponEnteringMaximizeMode) { |
| - DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| - display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| - gfx::Display::ROTATE_90); |
| + SetInternalDisplayRotation(gfx::Display::ROTATE_90); |
| // Trigger a non-maximize mode accelerometer update. Ensure that the display |
| // does not rotate. |
| @@ -417,4 +422,61 @@ TEST_F(MaximizeModeControllerTest, |
| EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| } |
| +// Tests that the screen rotation notifications are suppressed when |
| +// triggered by the accelerometer. |
| +TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) { |
| + test::TestSystemTrayDelegate* tray_delegate = |
| + static_cast<test::TestSystemTrayDelegate*>( |
| + Shell::GetInstance()->system_tray_delegate()); |
| + tray_delegate->set_should_show_display_notification(true); |
| + |
| + aura::Window* root = Shell::GetPrimaryRootWindow(); |
|
jonross
2014/05/09 14:57:33
only used for the event_generator
bruthig
2014/05/14 00:36:16
Done.
|
| + aura::test::EventGenerator event_generator(root, root); |
|
jonross
2014/05/09 14:57:33
unused?
bruthig
2014/05/14 00:36:16
Done.
|
| + message_center::MessageCenter* message_center = |
| + message_center::MessageCenter::Get(); |
| + |
| + // Make sure notifications are still displayed when |
| + // adjusting the screen rotation directly when not in maximize mode |
| + ASSERT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| + ASSERT_EQ(0u, message_center->NotificationCount()); |
| + EXPECT_FALSE(message_center->HasPopupNotifications()); |
|
jonross
2014/05/09 14:57:33
nit: use ASSERTs before causing changes, to confir
bruthig
2014/05/14 00:36:16
Done.
|
| + SetInternalDisplayRotation(gfx::Display::ROTATE_180); |
| + ASSERT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| + ASSERT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_TRUE(message_center->HasPopupNotifications()); |
| + |
| + // Clear all notifications |
| + message_center->RemoveAllNotifications(false); |
| + ASSERT_EQ(0u, message_center->NotificationCount()); |
| + EXPECT_FALSE(message_center->HasPopupNotifications()); |
| + |
| + // Trigger maximize mode by opening to 270. |
| + TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
| + gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
| + ASSERT_TRUE(IsMaximizeModeStarted()); |
| + maximize_mode_controller()->set_rotation_locked(false); |
| + |
| + // Make sure notifications are still displayed when |
| + // adjusting the screen rotation directly when in maximize mode |
| + ASSERT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| + SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| + ASSERT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| + ASSERT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_TRUE(message_center->HasPopupNotifications()); |
| + |
| + // Clear all notifications |
| + message_center->RemoveAllNotifications(false); |
| + ASSERT_EQ(0u, message_center->NotificationCount()); |
| + EXPECT_FALSE(message_center->HasPopupNotifications()); |
| + |
| + // Make sure notifications are blocked when adjusting the screen rotation |
| + // via the accelerometer while in maximize mode |
| + // Rotate the screen 90 degrees |
| + TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), |
| + gfx::Vector3dF(0.0f, 1.0f, 0.0f)); |
| + ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| + EXPECT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_FALSE(message_center->HasPopupNotifications()); |
| +} |
| + |
| } // namespace ash |