Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(428)

Side by Side Diff: ash/wm/maximize_mode/maximize_mode_controller_unittest.cc

Issue 289583002: Lock rotation when screen is manually rotated. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix non chromeOS builds Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 432 matching lines...) Expand 10 before | Expand all | Expand 10 after
443 ASSERT_EQ(0, volume_delegate->handle_volume_up_count()); 443 ASSERT_EQ(0, volume_delegate->handle_volume_up_count());
444 event_generator.PressKey(ui::VKEY_VOLUME_UP, 0); 444 event_generator.PressKey(ui::VKEY_VOLUME_UP, 0);
445 event_generator.ReleaseKey(ui::VKEY_VOLUME_UP, 0); 445 event_generator.ReleaseKey(ui::VKEY_VOLUME_UP, 0);
446 EXPECT_EQ(1, volume_delegate->handle_volume_up_count()); 446 EXPECT_EQ(1, volume_delegate->handle_volume_up_count());
447 } 447 }
448 448
449 TEST_F(MaximizeModeControllerTest, LaptopTest) { 449 TEST_F(MaximizeModeControllerTest, LaptopTest) {
450 // Feeds in sample accelerometer data and verifies that there are no 450 // Feeds in sample accelerometer data and verifies that there are no
451 // transitions into touchview / maximize mode while shaking the device around 451 // transitions into touchview / maximize mode while shaking the device around
452 // with the hinge at less than 180 degrees. 452 // with the hinge at less than 180 degrees.
453 ASSERT_TRUE(kAccelerometerLaptopModeTestDataLength % 6 == 0); 453 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6);
454 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { 454 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) {
455 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6], 455 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6],
456 kAccelerometerLaptopModeTestData[i * 6 + 1], 456 kAccelerometerLaptopModeTestData[i * 6 + 1],
457 kAccelerometerLaptopModeTestData[i * 6 + 2]); 457 kAccelerometerLaptopModeTestData[i * 6 + 2]);
458 gfx::Vector3dF lid(kAccelerometerLaptopModeTestData[i * 6 + 3], 458 gfx::Vector3dF lid(kAccelerometerLaptopModeTestData[i * 6 + 3],
459 kAccelerometerLaptopModeTestData[i * 6 + 4], 459 kAccelerometerLaptopModeTestData[i * 6 + 4],
460 kAccelerometerLaptopModeTestData[i * 6 + 5]); 460 kAccelerometerLaptopModeTestData[i * 6 + 5]);
461 TriggerAccelerometerUpdate(base, lid); 461 TriggerAccelerometerUpdate(base, lid);
462 // There are a lot of samples, so ASSERT rather than EXPECT to only generate 462 // There are a lot of samples, so ASSERT rather than EXPECT to only generate
463 // one failure rather than potentially hundreds. 463 // one failure rather than potentially hundreds.
464 ASSERT_FALSE(IsMaximizeModeStarted()); 464 ASSERT_FALSE(IsMaximizeModeStarted());
465 } 465 }
466 } 466 }
467 467
468 TEST_F(MaximizeModeControllerTest, MaximizeModeTest) { 468 TEST_F(MaximizeModeControllerTest, MaximizeModeTest) {
469 // Trigger maximize mode by opening to 270 to begin the test in maximize mode. 469 // Trigger maximize mode by opening to 270 to begin the test in maximize mode.
470 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f), 470 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
471 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); 471 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
472 ASSERT_TRUE(IsMaximizeModeStarted()); 472 ASSERT_TRUE(IsMaximizeModeStarted());
473 473
474 // Feeds in sample accelerometer data and verifies that there are no 474 // Feeds in sample accelerometer data and verifies that there are no
475 // transitions out of touchview / maximize mode while shaking the device 475 // transitions out of touchview / maximize mode while shaking the device
476 // around. 476 // around.
477 ASSERT_TRUE(kAccelerometerFullyOpenTestDataLength % 6 == 0); 477 ASSERT_EQ(0u, kAccelerometerFullyOpenTestDataLength % 6);
478 for (size_t i = 0; i < kAccelerometerFullyOpenTestDataLength / 6; ++i) { 478 for (size_t i = 0; i < kAccelerometerFullyOpenTestDataLength / 6; ++i) {
479 gfx::Vector3dF base(kAccelerometerFullyOpenTestData[i * 6], 479 gfx::Vector3dF base(kAccelerometerFullyOpenTestData[i * 6],
480 kAccelerometerFullyOpenTestData[i * 6 + 1], 480 kAccelerometerFullyOpenTestData[i * 6 + 1],
481 kAccelerometerFullyOpenTestData[i * 6 + 2]); 481 kAccelerometerFullyOpenTestData[i * 6 + 2]);
482 gfx::Vector3dF lid(kAccelerometerFullyOpenTestData[i * 6 + 3], 482 gfx::Vector3dF lid(kAccelerometerFullyOpenTestData[i * 6 + 3],
483 kAccelerometerFullyOpenTestData[i * 6 + 4], 483 kAccelerometerFullyOpenTestData[i * 6 + 4],
484 kAccelerometerFullyOpenTestData[i * 6 + 5]); 484 kAccelerometerFullyOpenTestData[i * 6 + 5]);
485 TriggerAccelerometerUpdate(base, lid); 485 TriggerAccelerometerUpdate(base, lid);
486 // 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
487 // one failure rather than potentially hundreds. 487 // one failure rather than potentially hundreds.
(...skipping 26 matching lines...) Expand all
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()->set_rotation_locked(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));
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 // Rotate the screen 90 degrees 589 // Rotate the screen 90 degrees
590 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); 590 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
591 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f), 591 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 1.0f, 0.0f),
592 gfx::Vector3dF(0.0f, 1.0f, 0.0f)); 592 gfx::Vector3dF(0.0f, 1.0f, 0.0f));
593 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); 593 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
594 EXPECT_EQ(0u, message_center->NotificationCount()); 594 EXPECT_EQ(0u, message_center->NotificationCount());
595 EXPECT_FALSE(message_center->HasPopupNotifications()); 595 EXPECT_FALSE(message_center->HasPopupNotifications());
596 } 596 }
597 #endif 597 #endif
598 598
599 // Tests that if a user has set a display rotation that it is restored upon
600 // exiting maximize mode.
601 TEST_F(MaximizeModeControllerTest, ResetUserRotationUponExit) {
602 DisplayManager* display_manager = Shell::GetInstance()->display_manager();
603 display_manager->SetDisplayRotation(gfx::Display::InternalDisplayId(),
604 gfx::Display::ROTATE_90);
605
606 // Trigger maximize mode
607 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, -1.0f),
608 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
609 ASSERT_TRUE(IsMaximizeModeStarted());
610
611 TriggerAccelerometerUpdate(gfx::Vector3dF(1.0f, 0.0f, 0.0f),
612 gfx::Vector3dF(1.0f, 0.0f, 0.0f));
613 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
614
615 // Exit maximize mode
616 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f),
617 gfx::Vector3dF(-1.0f, 0.0f, 0.0f));
618 EXPECT_FALSE(IsMaximizeModeStarted());
619 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
620 }
621
599 } // namespace ash 622 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/maximize_mode/maximize_mode_controller.cc ('k') | chrome/browser/chromeos/display/display_preferences.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698