| 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 2c9ecc692d2e7be28e1afa29b367c85137b3b62d..c9f8e071d2df4e83a6803d3362160bab31194812 100644
|
| --- a/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
|
| +++ b/ash/wm/maximize_mode/maximize_mode_controller_unittest.cc
|
| @@ -23,6 +23,10 @@
|
| #include "ui/gfx/geometry/vector3d_f.h"
|
| #include "ui/message_center/message_center.h"
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +#include "ash/content/display/screen_orientation_delegate_chromeos.h"
|
| +#endif
|
| +
|
| #if defined(USE_X11)
|
| #include "ui/events/test/events_test_utils_x11.h"
|
| #endif
|
| @@ -34,6 +38,17 @@ namespace {
|
| const float kDegreesToRadians = 3.1415926f / 180.0f;
|
| const float kMeanGravity = 9.8066f;
|
|
|
| +#if defined(OS_CHROMEOS)
|
| +bool rotation_locked() {
|
| + return Shell::GetInstance()->screen_orientation_delegate()->rotation_locked();
|
| +}
|
| +
|
| +void SetRotationLocked(bool rotation_locked) {
|
| + Shell::GetInstance()->screen_orientation_delegate()->SetRotationLocked(
|
| + rotation_locked);
|
| +}
|
| +#endif // OS_CHROMEOS
|
| +
|
| } // namespace
|
|
|
| // Test accelerometer data taken with the lid at less than 180 degrees while
|
| @@ -304,6 +319,7 @@ TEST_F(MaximizeModeControllerTest, HingeAligned) {
|
| EXPECT_TRUE(IsMaximizeModeStarted());
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| // Tests that accelerometer readings in each of the screen angles will trigger a
|
| // rotation of the internal display.
|
| TEST_F(MaximizeModeControllerTest, DisplayRotation) {
|
| @@ -326,6 +342,7 @@ TEST_F(MaximizeModeControllerTest, DisplayRotation) {
|
| gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f));
|
| EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
|
| }
|
| +#endif // OS_CHROMEOS
|
|
|
| // Tests that low angles are ignored by the accelerometer (i.e. when the device
|
| // is almost laying flat).
|
| @@ -353,6 +370,7 @@ TEST_F(MaximizeModeControllerTest, RotationIgnoresLowAngles) {
|
| EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| // Tests that the display will stick to the current orientation beyond the
|
| // halfway point, preventing frequent updates back and forth.
|
| TEST_F(MaximizeModeControllerTest, RotationSticky) {
|
| @@ -410,7 +428,7 @@ TEST_F(MaximizeModeControllerTest, RotationOnlyInMaximizeMode) {
|
| ASSERT_FALSE(IsMaximizeModeStarted());
|
| EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
|
| }
|
| -
|
| +#endif // OS_CHROMEOS
|
|
|
| TEST_F(MaximizeModeControllerTest, LaptopTest) {
|
| // Feeds in sample accelerometer data and verifies that there are no
|
| @@ -461,6 +479,7 @@ TEST_F(MaximizeModeControllerTest, MaximizeModeTest) {
|
| }
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| // Tests that the display will stick to its current orientation when the
|
| // rotation lock has been set.
|
| TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) {
|
| @@ -471,7 +490,7 @@ TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) {
|
|
|
| gfx::Vector3dF gravity(-kMeanGravity, 0.0f, 0.0f);
|
|
|
| - maximize_mode_controller()->SetRotationLocked(true);
|
| + SetRotationLocked(true);
|
|
|
| // Turn past the threshold for rotation.
|
| float degrees = 90.0;
|
| @@ -480,7 +499,7 @@ TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) {
|
| TriggerAccelerometerUpdate(gravity, gravity);
|
| EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
|
|
|
| - maximize_mode_controller()->SetRotationLocked(false);
|
| + SetRotationLocked(false);
|
| TriggerAccelerometerUpdate(gravity, gravity);
|
| EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
|
| }
|
| @@ -492,19 +511,18 @@ TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) {
|
| OpenLidToAngle(270.0f);
|
| ASSERT_TRUE(IsMaximizeModeStarted());
|
|
|
| - maximize_mode_controller()->SetRotationLocked(true);
|
| + SetRotationLocked(true);
|
|
|
| OpenLidToAngle(90.0f);
|
| EXPECT_FALSE(IsMaximizeModeStarted());
|
|
|
| // Send an update that would not relaunch MaximizeMode.
|
| OpenLidToAngle(90.0f);
|
| - EXPECT_FALSE(maximize_mode_controller()->rotation_locked());
|
| + EXPECT_FALSE(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) {
|
| @@ -542,7 +560,7 @@ TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) {
|
| // adjusting the screen rotation directly when in maximize mode
|
| ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
|
| SetInternalDisplayRotation(gfx::Display::ROTATE_270);
|
| - maximize_mode_controller()->SetRotationLocked(false);
|
| + SetRotationLocked(false);
|
| EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
|
| EXPECT_EQ(1u, message_center->NotificationCount());
|
| EXPECT_TRUE(message_center->HasPopupNotifications());
|
| @@ -562,7 +580,6 @@ TEST_F(MaximizeModeControllerTest, BlockRotationNotifications) {
|
| EXPECT_EQ(0u, message_center->NotificationCount());
|
| EXPECT_FALSE(message_center->HasPopupNotifications());
|
| }
|
| -#endif
|
|
|
| // Tests that if a user has set a display rotation that it is restored upon
|
| // exiting maximize mode.
|
| @@ -594,10 +611,11 @@ TEST_F(MaximizeModeControllerTest,
|
| // Trigger maximize mode by opening to 270.
|
| TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity),
|
| gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f));
|
| - ASSERT_FALSE(maximize_mode_controller()->rotation_locked());
|
| + ASSERT_FALSE(rotation_locked());
|
| SetInternalDisplayRotation(gfx::Display::ROTATE_270);
|
| - EXPECT_TRUE(maximize_mode_controller()->rotation_locked());
|
| + EXPECT_TRUE(rotation_locked());
|
| }
|
| +#endif // OS_CHROMEOS
|
|
|
| // Tests that if a user changes the display rotation, while rotation is locked,
|
| // that the updates are recorded. Upon exiting maximize mode the latest user
|
| @@ -616,6 +634,7 @@ TEST_F(MaximizeModeControllerTest, UpdateUserRotationWhileRotationLocked) {
|
| EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
|
| }
|
|
|
| +#if defined(OS_CHROMEOS)
|
| class MaximizeModeControllerSwitchesTest : public MaximizeModeControllerTest {
|
| public:
|
| MaximizeModeControllerSwitchesTest() {}
|
| @@ -644,5 +663,6 @@ TEST_F(MaximizeModeControllerSwitchesTest, IgnoreHingeAngles) {
|
| gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
|
| EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
|
| }
|
| +#endif // OS_CHROMEOS
|
|
|
| } // namespace ash
|
|
|