| 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 <math.h> | 5 #include <math.h> |
| 6 | 6 |
| 7 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 7 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 8 | 8 |
| 9 #include "ash/accelerometer/accelerometer_controller.h" | 9 #include "ash/accelerometer/accelerometer_controller.h" |
| 10 #include "ash/display/display_manager.h" | 10 #include "ash/display/display_manager.h" |
| 11 #include "ash/shell.h" | 11 #include "ash/shell.h" |
| 12 #include "ash/system/tray/system_tray_delegate.h" | 12 #include "ash/system/tray/system_tray_delegate.h" |
| 13 #include "ash/test/ash_test_base.h" | 13 #include "ash/test/ash_test_base.h" |
| 14 #include "ash/test/display_manager_test_api.h" | 14 #include "ash/test/display_manager_test_api.h" |
| 15 #include "ash/test/test_lock_state_controller_delegate.h" | 15 #include "ash/test/test_lock_state_controller_delegate.h" |
| 16 #include "ash/test/test_screenshot_delegate.h" | 16 #include "ash/test/test_screenshot_delegate.h" |
| 17 #include "ash/test/test_system_tray_delegate.h" | 17 #include "ash/test/test_system_tray_delegate.h" |
| 18 #include "ash/test/test_volume_control_delegate.h" | 18 #include "ash/test/test_volume_control_delegate.h" |
| 19 #include "base/test/simple_test_tick_clock.h" | 19 #include "base/test/simple_test_tick_clock.h" |
| 20 #include "ui/accelerometer/accelerometer_types.h" |
| 20 #include "ui/events/event_handler.h" | 21 #include "ui/events/event_handler.h" |
| 21 #include "ui/events/test/event_generator.h" | 22 #include "ui/events/test/event_generator.h" |
| 22 #include "ui/gfx/vector3d_f.h" | 23 #include "ui/gfx/vector3d_f.h" |
| 23 #include "ui/message_center/message_center.h" | 24 #include "ui/message_center/message_center.h" |
| 24 | 25 |
| 25 #if defined(USE_X11) | 26 #if defined(USE_X11) |
| 26 #include "ui/events/test/events_test_utils_x11.h" | 27 #include "ui/events/test/events_test_utils_x11.h" |
| 27 #endif | 28 #endif |
| 28 | 29 |
| 29 namespace ash { | 30 namespace ash { |
| 30 | 31 |
| 31 namespace { | 32 namespace { |
| 32 | 33 |
| 33 const float kDegreesToRadians = 3.14159265f / 180.0f; | 34 const float kDegreesToRadians = 3.1415926f / 180.0f; |
| 35 const float kMeanGravity = 9.8066f; |
| 34 | 36 |
| 35 } // namespace | 37 } // namespace |
| 36 | 38 |
| 37 // Test accelerometer data taken with the lid at less than 180 degrees while | 39 // Test accelerometer data taken with the lid at less than 180 degrees while |
| 38 // shaking the device around. The data is to be interpreted in groups of 6 where | 40 // shaking the device around. The data is to be interpreted in groups of 6 where |
| 39 // each 6 values corresponds to the X, Y, and Z readings from the base and lid | 41 // each 6 values corresponds to the X, Y, and Z readings from the base and lid |
| 40 // accelerometers in this order. | 42 // accelerometers in this order. |
| 41 extern const float kAccelerometerLaptopModeTestData[]; | 43 extern const float kAccelerometerLaptopModeTestData[]; |
| 42 extern const size_t kAccelerometerLaptopModeTestDataLength; | 44 extern const size_t kAccelerometerLaptopModeTestDataLength; |
| 43 | 45 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 69 maximize_mode_controller()); | 71 maximize_mode_controller()); |
| 70 test::AshTestBase::TearDown(); | 72 test::AshTestBase::TearDown(); |
| 71 } | 73 } |
| 72 | 74 |
| 73 MaximizeModeController* maximize_mode_controller() { | 75 MaximizeModeController* maximize_mode_controller() { |
| 74 return Shell::GetInstance()->maximize_mode_controller(); | 76 return Shell::GetInstance()->maximize_mode_controller(); |
| 75 } | 77 } |
| 76 | 78 |
| 77 void TriggerAccelerometerUpdate(const gfx::Vector3dF& base, | 79 void TriggerAccelerometerUpdate(const gfx::Vector3dF& base, |
| 78 const gfx::Vector3dF& lid) { | 80 const gfx::Vector3dF& lid) { |
| 79 maximize_mode_controller()->OnAccelerometerUpdated(base, lid); | 81 ui::AccelerometerUpdate update; |
| 82 update.Set(ui::ACCELEROMETER_SOURCE_ATTACHED_KEYBOARD, |
| 83 base.x(), base.y(), base.z()); |
| 84 update.Set(ui::ACCELEROMETER_SOURCE_SCREEN, |
| 85 lid.x(), lid.y(), lid.z()); |
| 86 maximize_mode_controller()->OnAccelerometerUpdated(update); |
| 80 } | 87 } |
| 81 | 88 |
| 82 bool IsMaximizeModeStarted() { | 89 bool IsMaximizeModeStarted() { |
| 83 return maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled(); | 90 return maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled(); |
| 84 } | 91 } |
| 85 | 92 |
| 86 gfx::Display::Rotation GetInternalDisplayRotation() const { | 93 gfx::Display::Rotation GetInternalDisplayRotation() const { |
| 87 return Shell::GetInstance()->display_manager()->GetDisplayInfo( | 94 return Shell::GetInstance()->display_manager()->GetDisplayInfo( |
| 88 gfx::Display::InternalDisplayId()).rotation(); | 95 gfx::Display::InternalDisplayId()).rotation(); |
| 89 } | 96 } |
| (...skipping 15 matching lines...) Expand all Loading... |
| 105 void AdvanceTickClock(const base::TimeDelta& delta) { | 112 void AdvanceTickClock(const base::TimeDelta& delta) { |
| 106 DCHECK(test_tick_clock_); | 113 DCHECK(test_tick_clock_); |
| 107 test_tick_clock_->Advance(delta); | 114 test_tick_clock_->Advance(delta); |
| 108 } | 115 } |
| 109 | 116 |
| 110 void OpenLidToAngle(float degrees) { | 117 void OpenLidToAngle(float degrees) { |
| 111 DCHECK(degrees >= 0.0f); | 118 DCHECK(degrees >= 0.0f); |
| 112 DCHECK(degrees <= 360.0f); | 119 DCHECK(degrees <= 360.0f); |
| 113 | 120 |
| 114 float radians = degrees * kDegreesToRadians; | 121 float radians = degrees * kDegreesToRadians; |
| 115 gfx::Vector3dF base_vector(1.0f, 0.0f, 0.0f); | 122 gfx::Vector3dF base_vector(0.0f, -kMeanGravity, 0.0f); |
| 116 gfx::Vector3dF lid_vector(cos(radians), 0.0f, sin(radians)); | 123 gfx::Vector3dF lid_vector(0.0f, |
| 124 kMeanGravity * cos(radians), |
| 125 kMeanGravity * sin(radians)); |
| 117 TriggerAccelerometerUpdate(base_vector, lid_vector); | 126 TriggerAccelerometerUpdate(base_vector, lid_vector); |
| 118 } | 127 } |
| 119 | 128 |
| 120 #if defined(OS_CHROMEOS) | 129 #if defined(OS_CHROMEOS) |
| 121 void OpenLid() { | 130 void OpenLid() { |
| 122 maximize_mode_controller()->LidEventReceived(true /* open */, | 131 maximize_mode_controller()->LidEventReceived(true /* open */, |
| 123 maximize_mode_controller()->tick_clock_->NowTicks()); | 132 maximize_mode_controller()->tick_clock_->NowTicks()); |
| 124 } | 133 } |
| 125 | 134 |
| 126 void CloseLid() { | 135 void CloseLid() { |
| (...skipping 135 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 EXPECT_TRUE(IsMaximizeModeStarted()); | 271 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 263 | 272 |
| 264 OpenLidToAngle(5.0f); | 273 OpenLidToAngle(5.0f); |
| 265 EXPECT_TRUE(IsMaximizeModeStarted()); | 274 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 266 } | 275 } |
| 267 | 276 |
| 268 // Tests that when the hinge is nearly vertically aligned, the current state | 277 // Tests that when the hinge is nearly vertically aligned, the current state |
| 269 // persists as the computed angle is highly inaccurate in this orientation. | 278 // persists as the computed angle is highly inaccurate in this orientation. |
| 270 TEST_F(MaximizeModeControllerTest, HingeAligned) { | 279 TEST_F(MaximizeModeControllerTest, HingeAligned) { |
| 271 // Laptop in normal orientation lid open 90 degrees. | 280 // Laptop in normal orientation lid open 90 degrees. |
| 272 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 281 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), |
| 273 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 282 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 274 EXPECT_FALSE(IsMaximizeModeStarted()); | 283 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 275 | 284 |
| 276 // Completely vertical. | 285 // Completely vertical. |
| 277 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.0f), | 286 TriggerAccelerometerUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f), |
| 278 gfx::Vector3dF(0.0f, -1.0f, 0.0f)); | 287 gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
| 279 EXPECT_FALSE(IsMaximizeModeStarted()); | 288 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 280 | 289 |
| 281 // Close to vertical but with hinge appearing to be open 270 degrees. | 290 // Close to vertical but with hinge appearing to be open 270 degrees. |
| 282 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), | 291 TriggerAccelerometerUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, -0.1f), |
| 283 gfx::Vector3dF(0.01f, -1.0f, 0.0f)); | 292 gfx::Vector3dF(kMeanGravity, 0.1f, 0.0f)); |
| 284 EXPECT_FALSE(IsMaximizeModeStarted()); | 293 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 285 | 294 |
| 286 // Flat and open 270 degrees should start maximize mode. | 295 // Flat and open 270 degrees should start maximize mode. |
| 287 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 296 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), |
| 288 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 297 gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
| 289 EXPECT_TRUE(IsMaximizeModeStarted()); | 298 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 290 | 299 |
| 291 // Normal 90 degree orientation but near vertical should stay in maximize | 300 // Normal 90 degree orientation but near vertical should stay in maximize |
| 292 // mode. | 301 // mode. |
| 293 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.01f), | 302 TriggerAccelerometerUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, -0.1f), |
| 294 gfx::Vector3dF(-0.01f, -1.0f, 0.0f)); | 303 gfx::Vector3dF(kMeanGravity, -0.1f, 0.0f)); |
| 295 EXPECT_TRUE(IsMaximizeModeStarted()); | 304 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 296 } | 305 } |
| 297 | 306 |
| 298 // Tests that accelerometer readings in each of the screen angles will trigger a | 307 // Tests that accelerometer readings in each of the screen angles will trigger a |
| 299 // rotation of the internal display. | 308 // rotation of the internal display. |
| 300 TEST_F(MaximizeModeControllerTest, DisplayRotation) { | 309 TEST_F(MaximizeModeControllerTest, DisplayRotation) { |
| 301 // Trigger maximize mode by opening to 270. | 310 // Trigger maximize mode by opening to 270. |
| 302 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 311 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 303 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 312 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 304 ASSERT_TRUE(IsMaximizeModeStarted()); | 313 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 305 | 314 |
| 306 // Now test rotating in all directions. | 315 // Now test rotating in all directions. |
| 307 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), | 316 TriggerAccelerometerUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f), |
| 308 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); | 317 gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); |
| 309 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 318 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 310 TriggerAccelerometerUpdate(gfx::Vector3dF(1.0f, 0.0f, 0.0f), | 319 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f), |
| 311 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 320 gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
| 312 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); | 321 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| 313 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -1.0f, 0.0f), | 322 TriggerAccelerometerUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f), |
| 314 gfx::Vector3dF(0.0f, -1.0f, 0.0f)); | 323 gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
| 315 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); | 324 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| 316 TriggerAccelerometerUpdate(gfx::Vector3dF(-1.0f, 0.0f, 0.0f), | 325 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f), |
| 317 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 326 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 318 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 327 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 319 } | 328 } |
| 320 | 329 |
| 321 // Tests that low angles are ignored by the accelerometer (i.e. when the device | 330 // Tests that low angles are ignored by the accelerometer (i.e. when the device |
| 322 // is almost laying flat). | 331 // is almost laying flat). |
| 323 TEST_F(MaximizeModeControllerTest, RotationIgnoresLowAngles) { | 332 TEST_F(MaximizeModeControllerTest, RotationIgnoresLowAngles) { |
| 324 // Trigger maximize mode by opening to 270. | 333 // Trigger maximize mode by opening to 270. |
| 325 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 334 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 326 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 335 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 327 ASSERT_TRUE(IsMaximizeModeStarted()); | 336 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 328 | 337 |
| 329 TriggerAccelerometerUpdate(gfx::Vector3dF(-1.0f, 0.0f, -1.0f), | 338 TriggerAccelerometerUpdate( |
| 330 gfx::Vector3dF(-1.0f, 0.0f, -1.0f)); | 339 gfx::Vector3dF(0.0f, kMeanGravity, kMeanGravity), |
| 340 gfx::Vector3dF(0.0f, -kMeanGravity, -kMeanGravity)); |
| 331 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 341 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 332 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.2f, -1.0f), | 342 TriggerAccelerometerUpdate(gfx::Vector3dF(-2.0f, 0.0f, kMeanGravity), |
| 333 gfx::Vector3dF(0.0f, 0.2f, -1.0f)); | 343 gfx::Vector3dF(-2.0f, 0.0f, -kMeanGravity)); |
| 334 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 344 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 335 TriggerAccelerometerUpdate(gfx::Vector3dF(0.2f, 0.0f, -1.0f), | 345 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -2.0f, kMeanGravity), |
| 336 gfx::Vector3dF(0.2f, 0.0f, -1.0f)); | 346 gfx::Vector3dF(0.0f, 2.0f, -kMeanGravity)); |
| 337 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 347 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 338 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -0.2f, -1.0f), | 348 TriggerAccelerometerUpdate(gfx::Vector3dF(2.0f, 0.0f, kMeanGravity), |
| 339 gfx::Vector3dF(0.0f, -0.2f, -1.0f)); | 349 gfx::Vector3dF(2.0f, 0.0f, -kMeanGravity)); |
| 340 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 350 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 341 TriggerAccelerometerUpdate(gfx::Vector3dF(-0.2f, 0.0f, -1.0f), | 351 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 2.0f, kMeanGravity), |
| 342 gfx::Vector3dF(-0.2f, 0.0f, -1.0f)); | 352 gfx::Vector3dF(0.0f, -2.0f, -kMeanGravity)); |
| 343 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 353 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 344 } | 354 } |
| 345 | 355 |
| 346 // Tests that the display will stick to the current orientation beyond the | 356 // Tests that the display will stick to the current orientation beyond the |
| 347 // halfway point, preventing frequent updates back and forth. | 357 // halfway point, preventing frequent updates back and forth. |
| 348 TEST_F(MaximizeModeControllerTest, RotationSticky) { | 358 TEST_F(MaximizeModeControllerTest, RotationSticky) { |
| 349 // Trigger maximize mode by opening to 270. | 359 // Trigger maximize mode by opening to 270. |
| 350 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 360 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 351 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 361 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 352 ASSERT_TRUE(IsMaximizeModeStarted()); | 362 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 353 | 363 |
| 354 gfx::Vector3dF gravity(-1.0f, 0.0f, 0.0f); | 364 gfx::Vector3dF gravity(0.0f, -kMeanGravity, 0.0f); |
| 355 TriggerAccelerometerUpdate(gravity, gravity); | 365 TriggerAccelerometerUpdate(gravity, gravity); |
| 356 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 366 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 357 | 367 |
| 358 // Turn past half-way point to next direction and rotation should remain | 368 // Turn past half-way point to next direction and rotation should remain |
| 359 // the same. | 369 // the same. |
| 360 float degrees = 50.0; | 370 float degrees = 50.0; |
| 361 gravity.set_x(-cos(degrees * kDegreesToRadians)); | 371 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
| 362 gravity.set_y(sin(degrees * kDegreesToRadians)); | 372 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
| 363 TriggerAccelerometerUpdate(gravity, gravity); | 373 TriggerAccelerometerUpdate(gravity, gravity); |
| 364 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 374 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 365 | 375 |
| 366 // Turn more and the screen should rotate. | 376 // Turn more and the screen should rotate. |
| 367 degrees = 70.0; | 377 degrees = 70.0; |
| 368 gravity.set_x(-cos(degrees * kDegreesToRadians)); | 378 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
| 369 gravity.set_y(sin(degrees * kDegreesToRadians)); | 379 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
| 370 TriggerAccelerometerUpdate(gravity, gravity); | 380 TriggerAccelerometerUpdate(gravity, gravity); |
| 371 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 381 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 372 | 382 |
| 373 // Turn back just beyond the half-way point and the new rotation should | 383 // Turn back just beyond the half-way point and the new rotation should |
| 374 // still be in effect. | 384 // still be in effect. |
| 375 degrees = 40.0; | 385 degrees = 40.0; |
| 376 gravity.set_x(-cos(degrees * kDegreesToRadians)); | 386 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
| 377 gravity.set_y(sin(degrees * kDegreesToRadians)); | 387 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
| 378 TriggerAccelerometerUpdate(gravity, gravity); | 388 TriggerAccelerometerUpdate(gravity, gravity); |
| 379 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 389 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 380 } | 390 } |
| 381 | 391 |
| 382 // Tests that the screen only rotates when maximize mode is engaged, and will | 392 // Tests that the screen only rotates when maximize mode is engaged, and will |
| 383 // return to the standard orientation on exiting maximize mode. | 393 // return to the standard orientation on exiting maximize mode. |
| 384 TEST_F(MaximizeModeControllerTest, RotationOnlyInMaximizeMode) { | 394 TEST_F(MaximizeModeControllerTest, RotationOnlyInMaximizeMode) { |
| 385 // Rotate on side with lid only open 90 degrees. | 395 // Rotate on side with lid only open 90 degrees. |
| 386 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.95f, 0.35f), | 396 TriggerAccelerometerUpdate(gfx::Vector3dF(-9.5f, 0.0f, -3.5f), |
| 387 gfx::Vector3dF(-0.35f, 0.95f, 0.0f)); | 397 gfx::Vector3dF(-9.5f, -3.5f, 0.0f)); |
| 388 ASSERT_FALSE(IsMaximizeModeStarted()); | 398 ASSERT_FALSE(IsMaximizeModeStarted()); |
| 389 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 399 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 390 | 400 |
| 391 // Open lid, screen should now rotate to match orientation. | 401 // Open lid, screen should now rotate to match orientation. |
| 392 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.95f, -0.35f), | 402 TriggerAccelerometerUpdate(gfx::Vector3dF(-9.5f, 0.0f, 3.5f), |
| 393 gfx::Vector3dF(-0.35f, 0.95f, 0.0f)); | 403 gfx::Vector3dF(-9.5f, -3.5f, 0.0f)); |
| 394 ASSERT_TRUE(IsMaximizeModeStarted()); | 404 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 395 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 405 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 396 | 406 |
| 397 // Close lid back to 90, screen should rotate back. | 407 // Close lid back to 90, screen should rotate back. |
| 398 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.95f, 0.35f), | 408 TriggerAccelerometerUpdate(gfx::Vector3dF(-9.5f, 0.0f, -3.5f), |
| 399 gfx::Vector3dF(-0.35f, 0.95f, 0.0f)); | 409 gfx::Vector3dF(-9.5f, -3.5f, 0.0f)); |
| 400 ASSERT_FALSE(IsMaximizeModeStarted()); | 410 ASSERT_FALSE(IsMaximizeModeStarted()); |
| 401 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 411 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 402 } | 412 } |
| 403 | 413 |
| 404 #if defined(OS_CHROMEOS) | 414 #if defined(OS_CHROMEOS) |
| 405 // Tests that a screenshot can be taken in maximize mode by holding volume down | 415 // Tests that a screenshot can be taken in maximize mode by holding volume down |
| 406 // and pressing power. | 416 // and pressing power. |
| 407 TEST_F(MaximizeModeControllerTest, Screenshot) { | 417 TEST_F(MaximizeModeControllerTest, Screenshot) { |
| 408 Shell::GetInstance()->lock_state_controller()->SetDelegate( | 418 Shell::GetInstance()->lock_state_controller()->SetDelegate( |
| 409 new test::TestLockStateControllerDelegate); | 419 new test::TestLockStateControllerDelegate); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 426 event_generator.PressKey(ui::VKEY_POWER, 0); | 436 event_generator.PressKey(ui::VKEY_POWER, 0); |
| 427 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | 437 event_generator.ReleaseKey(ui::VKEY_POWER, 0); |
| 428 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | 438 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); |
| 429 event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0); | 439 event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0); |
| 430 } | 440 } |
| 431 #endif // OS_CHROMEOS | 441 #endif // OS_CHROMEOS |
| 432 | 442 |
| 433 TEST_F(MaximizeModeControllerTest, LaptopTest) { | 443 TEST_F(MaximizeModeControllerTest, LaptopTest) { |
| 434 // Feeds in sample accelerometer data and verifies that there are no | 444 // Feeds in sample accelerometer data and verifies that there are no |
| 435 // transitions into touchview / maximize mode while shaking the device around | 445 // transitions into touchview / maximize mode while shaking the device around |
| 436 // with the hinge at less than 180 degrees. | 446 // with the hinge at less than 180 degrees. Note the conversion from device |
| 447 // data to accelerometer updates consistent with accelerometer_reader.cc. |
| 437 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6); | 448 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6); |
| 438 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { | 449 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { |
| 439 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6], | 450 gfx::Vector3dF base(-kAccelerometerLaptopModeTestData[i * 6 + 1], |
| 440 kAccelerometerLaptopModeTestData[i * 6 + 1], | 451 -kAccelerometerLaptopModeTestData[i * 6], |
| 441 kAccelerometerLaptopModeTestData[i * 6 + 2]); | 452 -kAccelerometerLaptopModeTestData[i * 6 + 2]); |
| 442 gfx::Vector3dF lid(kAccelerometerLaptopModeTestData[i * 6 + 3], | 453 base.Scale(kMeanGravity); |
| 443 kAccelerometerLaptopModeTestData[i * 6 + 4], | 454 gfx::Vector3dF lid(-kAccelerometerLaptopModeTestData[i * 6 + 4], |
| 455 kAccelerometerLaptopModeTestData[i * 6 + 3], |
| 444 kAccelerometerLaptopModeTestData[i * 6 + 5]); | 456 kAccelerometerLaptopModeTestData[i * 6 + 5]); |
| 457 lid.Scale(kMeanGravity); |
| 445 TriggerAccelerometerUpdate(base, lid); | 458 TriggerAccelerometerUpdate(base, lid); |
| 446 // There are a lot of samples, so ASSERT rather than EXPECT to only generate | 459 // There are a lot of samples, so ASSERT rather than EXPECT to only generate |
| 447 // one failure rather than potentially hundreds. | 460 // one failure rather than potentially hundreds. |
| 448 ASSERT_FALSE(IsMaximizeModeStarted()); | 461 ASSERT_FALSE(IsMaximizeModeStarted()); |
| 449 } | 462 } |
| 450 } | 463 } |
| 451 | 464 |
| 452 TEST_F(MaximizeModeControllerTest, MaximizeModeTest) { | 465 TEST_F(MaximizeModeControllerTest, MaximizeModeTest) { |
| 453 // Trigger maximize mode by opening to 270 to begin the test in maximize mode. | 466 // Trigger maximize mode by opening to 270 to begin the test in maximize mode. |
| 454 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 467 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 455 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 468 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 456 ASSERT_TRUE(IsMaximizeModeStarted()); | 469 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 457 | 470 |
| 458 // Feeds in sample accelerometer data and verifies that there are no | 471 // Feeds in sample accelerometer data and verifies that there are no |
| 459 // transitions out of touchview / maximize mode while shaking the device | 472 // transitions out of touchview / maximize mode while shaking the device |
| 460 // around. | 473 // around. Note the conversion from device data to accelerometer updates |
| 474 // consistent with accelerometer_reader.cc. |
| 461 ASSERT_EQ(0u, kAccelerometerFullyOpenTestDataLength % 6); | 475 ASSERT_EQ(0u, kAccelerometerFullyOpenTestDataLength % 6); |
| 462 for (size_t i = 0; i < kAccelerometerFullyOpenTestDataLength / 6; ++i) { | 476 for (size_t i = 0; i < kAccelerometerFullyOpenTestDataLength / 6; ++i) { |
| 463 gfx::Vector3dF base(kAccelerometerFullyOpenTestData[i * 6], | 477 gfx::Vector3dF base(-kAccelerometerFullyOpenTestData[i * 6 + 1], |
| 464 kAccelerometerFullyOpenTestData[i * 6 + 1], | 478 -kAccelerometerFullyOpenTestData[i * 6], |
| 465 kAccelerometerFullyOpenTestData[i * 6 + 2]); | 479 -kAccelerometerFullyOpenTestData[i * 6 + 2]); |
| 466 gfx::Vector3dF lid(kAccelerometerFullyOpenTestData[i * 6 + 3], | 480 base.Scale(kMeanGravity); |
| 467 kAccelerometerFullyOpenTestData[i * 6 + 4], | 481 gfx::Vector3dF lid(-kAccelerometerFullyOpenTestData[i * 6 + 4], |
| 482 kAccelerometerFullyOpenTestData[i * 6 + 3], |
| 468 kAccelerometerFullyOpenTestData[i * 6 + 5]); | 483 kAccelerometerFullyOpenTestData[i * 6 + 5]); |
| 484 lid.Scale(kMeanGravity); |
| 469 TriggerAccelerometerUpdate(base, lid); | 485 TriggerAccelerometerUpdate(base, lid); |
| 470 // There are a lot of samples, so ASSERT rather than EXPECT to only generate | 486 // There are a lot of samples, so ASSERT rather than EXPECT to only generate |
| 471 // one failure rather than potentially hundreds. | 487 // one failure rather than potentially hundreds. |
| 472 ASSERT_TRUE(IsMaximizeModeStarted()); | 488 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 473 } | 489 } |
| 474 } | 490 } |
| 475 | 491 |
| 476 // Tests that the display will stick to its current orientation when the | 492 // Tests that the display will stick to its current orientation when the |
| 477 // rotation lock has been set. | 493 // rotation lock has been set. |
| 478 TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) { | 494 TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) { |
| 479 // Trigger maximize mode by opening to 270. | 495 // Trigger maximize mode by opening to 270. |
| 480 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 496 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 481 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 497 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 482 ASSERT_TRUE(IsMaximizeModeStarted()); | 498 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 483 | 499 |
| 484 gfx::Vector3dF gravity(-1.0f, 0.0f, 0.0f); | 500 gfx::Vector3dF gravity(-kMeanGravity, 0.0f, 0.0f); |
| 485 | 501 |
| 486 maximize_mode_controller()->SetRotationLocked(true); | 502 maximize_mode_controller()->SetRotationLocked(true); |
| 487 | 503 |
| 488 // Turn past the threshold for rotation. | 504 // Turn past the threshold for rotation. |
| 489 float degrees = 90.0; | 505 float degrees = 90.0; |
| 490 gravity.set_x(-cos(degrees * kDegreesToRadians)); | 506 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
| 491 gravity.set_y(sin(degrees * kDegreesToRadians)); | 507 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
| 492 TriggerAccelerometerUpdate(gravity, gravity); | 508 TriggerAccelerometerUpdate(gravity, gravity); |
| 493 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 509 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 494 | 510 |
| 495 maximize_mode_controller()->SetRotationLocked(false); | 511 maximize_mode_controller()->SetRotationLocked(false); |
| 496 TriggerAccelerometerUpdate(gravity, gravity); | 512 TriggerAccelerometerUpdate(gravity, gravity); |
| 497 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 513 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 498 } | 514 } |
| 499 | 515 |
| 500 // Tests that when MaximizeModeController turns off MaximizeMode that on the | 516 // Tests that when MaximizeModeController turns off MaximizeMode that on the |
| 501 // next accelerometer update the rotation lock is cleared. | 517 // next accelerometer update the rotation lock is cleared. |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 537 SetInternalDisplayRotation(gfx::Display::ROTATE_180); | 553 SetInternalDisplayRotation(gfx::Display::ROTATE_180); |
| 538 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); | 554 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| 539 EXPECT_EQ(1u, message_center->NotificationCount()); | 555 EXPECT_EQ(1u, message_center->NotificationCount()); |
| 540 EXPECT_TRUE(message_center->HasPopupNotifications()); | 556 EXPECT_TRUE(message_center->HasPopupNotifications()); |
| 541 | 557 |
| 542 // Reset the screen rotation. | 558 // Reset the screen rotation. |
| 543 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 559 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
| 544 // Clear all notifications | 560 // Clear all notifications |
| 545 message_center->RemoveAllNotifications(false); | 561 message_center->RemoveAllNotifications(false); |
| 546 // Trigger maximize mode by opening to 270. | 562 // Trigger maximize mode by opening to 270. |
| 547 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 563 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 548 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 564 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 549 EXPECT_TRUE(IsMaximizeModeStarted()); | 565 EXPECT_TRUE(IsMaximizeModeStarted()); |
| 550 EXPECT_EQ(0u, message_center->NotificationCount()); | 566 EXPECT_EQ(0u, message_center->NotificationCount()); |
| 551 EXPECT_FALSE(message_center->HasPopupNotifications()); | 567 EXPECT_FALSE(message_center->HasPopupNotifications()); |
| 552 | 568 |
| 553 // Make sure notifications are still displayed when | 569 // Make sure notifications are still displayed when |
| 554 // adjusting the screen rotation directly when in maximize mode | 570 // adjusting the screen rotation directly when in maximize mode |
| 555 ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); | 571 ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| 556 SetInternalDisplayRotation(gfx::Display::ROTATE_270); | 572 SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| 557 maximize_mode_controller()->SetRotationLocked(false); | 573 maximize_mode_controller()->SetRotationLocked(false); |
| 558 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); | 574 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
| 559 EXPECT_EQ(1u, message_center->NotificationCount()); | 575 EXPECT_EQ(1u, message_center->NotificationCount()); |
| 560 EXPECT_TRUE(message_center->HasPopupNotifications()); | 576 EXPECT_TRUE(message_center->HasPopupNotifications()); |
| 561 | 577 |
| 562 // Clear all notifications | 578 // Clear all notifications |
| 563 message_center->RemoveAllNotifications(false); | 579 message_center->RemoveAllNotifications(false); |
| 564 EXPECT_EQ(0u, message_center->NotificationCount()); | 580 EXPECT_EQ(0u, message_center->NotificationCount()); |
| 565 EXPECT_FALSE(message_center->HasPopupNotifications()); | 581 EXPECT_FALSE(message_center->HasPopupNotifications()); |
| 566 | 582 |
| 567 // Make sure notifications are blocked when adjusting the screen rotation | 583 // Make sure notifications are blocked when adjusting the screen rotation |
| 568 // via the accelerometer while in maximize mode | 584 // via the accelerometer while in maximize mode |
| 569 // Rotate the screen 90 degrees | 585 // Rotate the screen 90 degrees |
| 570 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 586 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 571 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), | 587 TriggerAccelerometerUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f), |
| 572 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); | 588 gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); |
| 573 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 589 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 574 EXPECT_EQ(0u, message_center->NotificationCount()); | 590 EXPECT_EQ(0u, message_center->NotificationCount()); |
| 575 EXPECT_FALSE(message_center->HasPopupNotifications()); | 591 EXPECT_FALSE(message_center->HasPopupNotifications()); |
| 576 } | 592 } |
| 577 #endif | 593 #endif |
| 578 | 594 |
| 579 // Tests that if a user has set a display rotation that it is restored upon | 595 // Tests that if a user has set a display rotation that it is restored upon |
| 580 // exiting maximize mode. | 596 // exiting maximize mode. |
| 581 TEST_F(MaximizeModeControllerTest, ResetUserRotationUponExit) { | 597 TEST_F(MaximizeModeControllerTest, ResetUserRotationUponExit) { |
| 582 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); | 598 DisplayManager* display_manager = Shell::GetInstance()->display_manager(); |
| 583 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), | 599 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(), |
| 584 gfx::Display::ROTATE_90); | 600 gfx::Display::ROTATE_90); |
| 585 | 601 |
| 586 // Trigger maximize mode | 602 // Trigger maximize mode |
| 587 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 603 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 588 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 604 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 589 ASSERT_TRUE(IsMaximizeModeStarted()); | 605 ASSERT_TRUE(IsMaximizeModeStarted()); |
| 590 | 606 |
| 591 TriggerAccelerometerUpdate(gfx::Vector3dF(1.0f, 0.0f, 0.0f), | 607 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f), |
| 592 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 608 gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
| 593 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); | 609 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
| 594 | 610 |
| 595 // Exit maximize mode | 611 // Exit maximize mode |
| 596 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 612 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), |
| 597 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 613 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 598 EXPECT_FALSE(IsMaximizeModeStarted()); | 614 EXPECT_FALSE(IsMaximizeModeStarted()); |
| 599 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 615 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
| 600 } | 616 } |
| 601 | 617 |
| 602 // Tests that if a user sets a display rotation that accelerometer rotation | 618 // Tests that if a user sets a display rotation that accelerometer rotation |
| 603 // becomes locked. | 619 // becomes locked. |
| 604 TEST_F(MaximizeModeControllerTest, | 620 TEST_F(MaximizeModeControllerTest, |
| 605 NonAccelerometerRotationChangesLockRotation) { | 621 NonAccelerometerRotationChangesLockRotation) { |
| 606 // Trigger maximize mode by opening to 270. | 622 // Trigger maximize mode by opening to 270. |
| 607 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 623 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 608 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 624 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 609 ASSERT_FALSE(maximize_mode_controller()->rotation_locked()); | 625 ASSERT_FALSE(maximize_mode_controller()->rotation_locked()); |
| 610 SetInternalDisplayRotation(gfx::Display::ROTATE_270); | 626 SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| 611 EXPECT_TRUE(maximize_mode_controller()->rotation_locked()); | 627 EXPECT_TRUE(maximize_mode_controller()->rotation_locked()); |
| 612 } | 628 } |
| 613 | 629 |
| 614 // Tests that if a user changes the display rotation, while rotation is locked, | 630 // Tests that if a user changes the display rotation, while rotation is locked, |
| 615 // that the updates are recorded. Upon exiting maximize mode the latest user | 631 // that the updates are recorded. Upon exiting maximize mode the latest user |
| 616 // rotation should be applied. | 632 // rotation should be applied. |
| 617 TEST_F(MaximizeModeControllerTest, UpdateUserRotationWhileRotationLocked) { | 633 TEST_F(MaximizeModeControllerTest, UpdateUserRotationWhileRotationLocked) { |
| 618 // Trigger maximize mode by opening to 270. | 634 // Trigger maximize mode by opening to 270. |
| 619 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 635 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, kMeanGravity), |
| 620 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 636 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 621 SetInternalDisplayRotation(gfx::Display::ROTATE_270); | 637 SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| 622 // User sets rotation to the same rotation that the display was at when | 638 // User sets rotation to the same rotation that the display was at when |
| 623 // maximize mode was activated. | 639 // maximize mode was activated. |
| 624 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 640 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
| 625 // Exit maximize mode | 641 // Exit maximize mode |
| 626 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 642 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -kMeanGravity), |
| 627 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 643 gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
| 628 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 644 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
| 629 } | 645 } |
| 630 | 646 |
| 631 } // namespace ash | 647 } // namespace ash |
| OLD | NEW |