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 41131d3f433954dff413156c6956256df2011c5f..5509107429605e2cd18e82ed3755a7cf453f9a8b 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()); |
@@ -338,7 +345,7 @@ TEST_F(MaximizeModeControllerTest, BlocksKeyboardAndMouse) { |
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); |
@@ -503,4 +510,65 @@ TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { |
EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); |
} |
+// The TrayDisplay class that is responsible for adding/updating MessageCenter |
+// notifications is only added to the SystemTray on ChromeOS. |
+#if defined(OS_CHROMEOS) |
+// 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_FALSE(IsMaximizeModeStarted()); |
+ 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()); |
+ |
+ // Reset the screen rotation. |
+ SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
+ // 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)); |
+ EXPECT_TRUE(IsMaximizeModeStarted()); |
+ EXPECT_EQ(0u, 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(0u, message_center->NotificationCount()); |
+ EXPECT_FALSE(message_center->HasPopupNotifications()); |
+} |
+#endif |
+ |
} // namespace ash |