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 3dcd076fc8dfb3c23e3921196d896558f99c65b2..ce62e34965b3cc5aa472e7f56212fe0175a94017 100644 |
| --- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| +++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc |
| @@ -12,10 +12,12 @@ |
| #include "ash/test/display_manager_test_api.h" |
| #include "ash/test/test_lock_state_controller_delegate.h" |
| #include "ash/test/test_screenshot_delegate.h" |
| +#include "ash/test/test_system_tray_delegate.h" |
| #include "ash/test/test_volume_control_delegate.h" |
| #include "ui/aura/test/event_generator.h" |
| #include "ui/events/event_handler.h" |
| #include "ui/gfx/vector3d_f.h" |
| +#include "ui/message_center/message_center.h" |
| namespace ash { |
| @@ -112,6 +114,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); |
| }; |
| @@ -152,7 +159,7 @@ TEST_F(MaximizeModeControllerTest, EnterExitThresholds) { |
| // Tests that when the hinge is nearly vertically aligned, the current state |
| // persists as the computed angle is highly inaccurate in this orientation. |
| TEST_F(MaximizeModeControllerTest, HingeAligned) { |
| - // Laptop in normal orientation lid open 90 degrees. |
| + // Laptop in normal orientation lid open 90 degrees. |
| TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
| gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
| EXPECT_FALSE(IsMaximizeModeStarted()); |
| @@ -313,7 +320,7 @@ TEST_F(MaximizeModeControllerTest, BlocksKeyboard) { |
| EXPECT_EQ(0u, counter.event_count()); |
| counter.reset(); |
| - // Touch should not be blocked. |
| + // Touch should not be blocked. |
| event_generator.PressTouch(); |
| event_generator.ReleaseTouch(); |
| EXPECT_GT(counter.event_count(), 0u); |
| @@ -478,4 +485,59 @@ TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { |
| EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); |
| } |
| +// 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); |
| + |
| + 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_NE(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| + ASSERT_EQ(0u, message_center->NotificationCount()); |
| + ASSERT_FALSE(message_center->HasPopupNotifications()); |
| + SetInternalDisplayRotation(gfx::Display::ROTATE_180); |
| + EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| + EXPECT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_TRUE(message_center->HasPopupNotifications()); |
| + |
| + // Clear all notifications |
| + message_center->RemoveAllNotifications(false); |
| + // Trigger maximize mode by opening to 270. |
| + TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
| + gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
| + maximize_mode_controller()->set_rotation_locked(false); |
|
jonross
2014/05/14 01:00:39
Is this being triggered to require disabling?
flackr
2014/05/14 01:48:33
A SetInternalDisplayRotation(ROTATE_0...) would pr
bruthig
2014/05/14 18:48:49
Done.
|
| + EXPECT_TRUE(IsMaximizeModeStarted()); |
| + EXPECT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_FALSE(message_center->HasPopupNotifications()); |
| + |
| + // Make sure notifications are still displayed when |
| + // adjusting the screen rotation directly when in maximize mode |
| + ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| + SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| + EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| + EXPECT_EQ(1u, message_center->NotificationCount()); |
| + EXPECT_TRUE(message_center->HasPopupNotifications()); |
| + |
| + // Clear all notifications |
| + message_center->RemoveAllNotifications(false); |
| + EXPECT_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 |
| + ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| + 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 |