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 "ash/wm/maximize_mode/maximize_mode_controller.h" | 5 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
6 | 6 |
7 #include "ash/accelerometer/accelerometer_controller.h" | 7 #include "ash/accelerometer/accelerometer_controller.h" |
8 #include "ash/display/display_manager.h" | 8 #include "ash/display/display_manager.h" |
9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 481 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
492 // 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 |
493 // rotation lock has been set. | 493 // rotation lock has been set. |
494 TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) { | 494 TEST_F(MaximizeModeControllerTest, RotationLockPreventsRotation) { |
495 // Trigger maximize mode by opening to 270. | 495 // Trigger maximize mode by opening to 270. |
496 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 496 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
497 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 497 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
498 ASSERT_TRUE(IsMaximizeModeStarted()); | 498 ASSERT_TRUE(IsMaximizeModeStarted()); |
499 | 499 |
500 gfx::Vector3dF gravity(-1.0f, 0.0f, 0.0f); | 500 gfx::Vector3dF gravity(-1.0f, 0.0f, 0.0f); |
501 | 501 |
502 maximize_mode_controller()->set_rotation_locked(true); | 502 maximize_mode_controller()->SetRotationLocked(true); |
503 | 503 |
504 // Turn past the threshold for rotation. | 504 // Turn past the threshold for rotation. |
505 float degrees = 90.0; | 505 float degrees = 90.0; |
506 gravity.set_x(-cos(degrees * kDegreesToRadians)); | 506 gravity.set_x(-cos(degrees * kDegreesToRadians)); |
507 gravity.set_y(sin(degrees * kDegreesToRadians)); | 507 gravity.set_y(sin(degrees * kDegreesToRadians)); |
508 TriggerAccelerometerUpdate(gravity, gravity); | 508 TriggerAccelerometerUpdate(gravity, gravity); |
509 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 509 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
510 | 510 |
511 maximize_mode_controller()->set_rotation_locked(false); | 511 maximize_mode_controller()->SetRotationLocked(false); |
512 TriggerAccelerometerUpdate(gravity, gravity); | 512 TriggerAccelerometerUpdate(gravity, gravity); |
513 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 513 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
514 } | 514 } |
515 | 515 |
516 // Tests that when MaximizeModeController turns off MaximizeMode that on the | 516 // Tests that when MaximizeModeController turns off MaximizeMode that on the |
517 // next accelerometer update the rotation lock is cleared. | 517 // next accelerometer update the rotation lock is cleared. |
518 TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { | 518 TEST_F(MaximizeModeControllerTest, ExitingMaximizeModeClearRotationLock) { |
519 // The base remains steady. | 519 // The base remains steady. |
520 gfx::Vector3dF base(0.0f, 0.0f, 1.0f); | 520 gfx::Vector3dF base(0.0f, 0.0f, 1.0f); |
521 | 521 |
522 // Trigger maximize mode by opening to 270. | 522 // Trigger maximize mode by opening to 270. |
523 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 523 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
524 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 524 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
525 ASSERT_TRUE(IsMaximizeModeStarted()); | 525 ASSERT_TRUE(IsMaximizeModeStarted()); |
526 | 526 |
527 maximize_mode_controller()->set_rotation_locked(true); | 527 maximize_mode_controller()->SetRotationLocked(true); |
528 | 528 |
529 // Open 90 degrees. | 529 // Open 90 degrees. |
530 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 530 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
531 EXPECT_FALSE(IsMaximizeModeStarted()); | 531 EXPECT_FALSE(IsMaximizeModeStarted()); |
532 | 532 |
533 // Send an update that would not relaunch MaximizeMode. 90 degrees. | 533 // Send an update that would not relaunch MaximizeMode. 90 degrees. |
534 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 534 TriggerAccelerometerUpdate(base, gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
535 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); | 535 EXPECT_FALSE(maximize_mode_controller()->rotation_locked()); |
536 } | 536 } |
537 | 537 |
(...skipping 30 matching lines...) Expand all Loading... |
568 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), | 568 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
569 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 569 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
570 EXPECT_TRUE(IsMaximizeModeStarted()); | 570 EXPECT_TRUE(IsMaximizeModeStarted()); |
571 EXPECT_EQ(0u, message_center->NotificationCount()); | 571 EXPECT_EQ(0u, message_center->NotificationCount()); |
572 EXPECT_FALSE(message_center->HasPopupNotifications()); | 572 EXPECT_FALSE(message_center->HasPopupNotifications()); |
573 | 573 |
574 // Make sure notifications are still displayed when | 574 // Make sure notifications are still displayed when |
575 // adjusting the screen rotation directly when in maximize mode | 575 // adjusting the screen rotation directly when in maximize mode |
576 ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); | 576 ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
577 SetInternalDisplayRotation(gfx::Display::ROTATE_270); | 577 SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| 578 maximize_mode_controller()->SetRotationLocked(false); |
578 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); | 579 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
579 EXPECT_EQ(1u, message_center->NotificationCount()); | 580 EXPECT_EQ(1u, message_center->NotificationCount()); |
580 EXPECT_TRUE(message_center->HasPopupNotifications()); | 581 EXPECT_TRUE(message_center->HasPopupNotifications()); |
581 | 582 |
582 // Clear all notifications | 583 // Clear all notifications |
583 message_center->RemoveAllNotifications(false); | 584 message_center->RemoveAllNotifications(false); |
584 EXPECT_EQ(0u, message_center->NotificationCount()); | 585 EXPECT_EQ(0u, message_center->NotificationCount()); |
585 EXPECT_FALSE(message_center->HasPopupNotifications()); | 586 EXPECT_FALSE(message_center->HasPopupNotifications()); |
586 | 587 |
587 // Make sure notifications are blocked when adjusting the screen rotation | 588 // Make sure notifications are blocked when adjusting the screen rotation |
(...skipping 24 matching lines...) Expand all Loading... |
612 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | 613 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); |
613 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); | 614 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
614 | 615 |
615 // Exit maximize mode | 616 // Exit maximize mode |
616 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 617 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
617 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 618 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
618 EXPECT_FALSE(IsMaximizeModeStarted()); | 619 EXPECT_FALSE(IsMaximizeModeStarted()); |
619 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 620 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
620 } | 621 } |
621 | 622 |
| 623 // Tests that if a user sets a display rotation that accelerometer rotation |
| 624 // becomes locked. |
| 625 TEST_F(MaximizeModeControllerTest, |
| 626 NonAccelerometerRotationChangesLockRotation) { |
| 627 // Trigger maximize mode by opening to 270. |
| 628 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), |
| 629 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
| 630 ASSERT_FALSE(maximize_mode_controller()->rotation_locked()); |
| 631 SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
| 632 EXPECT_TRUE(maximize_mode_controller()->rotation_locked()); |
| 633 } |
| 634 |
622 } // namespace ash | 635 } // namespace ash |
OLD | NEW |