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" | |
16 #include "ash/test/test_screenshot_delegate.h" | |
17 #include "ash/test/test_system_tray_delegate.h" | 15 #include "ash/test/test_system_tray_delegate.h" |
18 #include "ash/test/test_volume_control_delegate.h" | 16 #include "ash/test/test_volume_control_delegate.h" |
19 #include "base/test/simple_test_tick_clock.h" | 17 #include "base/test/simple_test_tick_clock.h" |
20 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
21 #include "ui/events/test/event_generator.h" | 19 #include "ui/events/test/event_generator.h" |
22 #include "ui/gfx/vector3d_f.h" | 20 #include "ui/gfx/vector3d_f.h" |
23 #include "ui/message_center/message_center.h" | 21 #include "ui/message_center/message_center.h" |
24 | 22 |
25 #if defined(USE_X11) | 23 #if defined(USE_X11) |
26 #include "ui/events/test/events_test_utils_x11.h" | 24 #include "ui/events/test/events_test_utils_x11.h" |
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 ASSERT_TRUE(IsMaximizeModeStarted()); | 392 ASSERT_TRUE(IsMaximizeModeStarted()); |
395 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); | 393 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
396 | 394 |
397 // Close lid back to 90, screen should rotate back. | 395 // Close lid back to 90, screen should rotate back. |
398 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.95f, 0.35f), | 396 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.95f, 0.35f), |
399 gfx::Vector3dF(-0.35f, 0.95f, 0.0f)); | 397 gfx::Vector3dF(-0.35f, 0.95f, 0.0f)); |
400 ASSERT_FALSE(IsMaximizeModeStarted()); | 398 ASSERT_FALSE(IsMaximizeModeStarted()); |
401 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 399 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
402 } | 400 } |
403 | 401 |
404 #if defined(OS_CHROMEOS) | |
405 // Tests that a screenshot can be taken in maximize mode by holding volume down | |
406 // and pressing power. | |
407 TEST_F(MaximizeModeControllerTest, Screenshot) { | |
408 Shell::GetInstance()->lock_state_controller()->SetDelegate( | |
409 new test::TestLockStateControllerDelegate); | |
410 aura::Window* root = Shell::GetPrimaryRootWindow(); | |
411 ui::test::EventGenerator event_generator(root, root); | |
412 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | |
413 delegate->set_can_take_screenshot(true); | |
414 | |
415 // Open up 270 degrees. | |
416 OpenLidToAngle(270.0f); | |
417 ASSERT_TRUE(IsMaximizeModeStarted()); | |
418 | |
419 // Pressing power alone does not take a screenshot. | |
420 event_generator.PressKey(ui::VKEY_POWER, 0); | |
421 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | |
422 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | |
423 | |
424 // Holding volume down and pressing power takes a screenshot. | |
425 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); | |
426 event_generator.PressKey(ui::VKEY_POWER, 0); | |
427 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | |
428 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | |
429 event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0); | |
430 } | |
431 #endif // OS_CHROMEOS | |
432 | 402 |
433 TEST_F(MaximizeModeControllerTest, LaptopTest) { | 403 TEST_F(MaximizeModeControllerTest, LaptopTest) { |
434 // Feeds in sample accelerometer data and verifies that there are no | 404 // Feeds in sample accelerometer data and verifies that there are no |
435 // transitions into touchview / maximize mode while shaking the device around | 405 // transitions into touchview / maximize mode while shaking the device around |
436 // with the hinge at less than 180 degrees. | 406 // with the hinge at less than 180 degrees. |
437 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6); | 407 ASSERT_EQ(0u, kAccelerometerLaptopModeTestDataLength % 6); |
438 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { | 408 for (size_t i = 0; i < kAccelerometerLaptopModeTestDataLength / 6; ++i) { |
439 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6], | 409 gfx::Vector3dF base(kAccelerometerLaptopModeTestData[i * 6], |
440 kAccelerometerLaptopModeTestData[i * 6 + 1], | 410 kAccelerometerLaptopModeTestData[i * 6 + 1], |
441 kAccelerometerLaptopModeTestData[i * 6 + 2]); | 411 kAccelerometerLaptopModeTestData[i * 6 + 2]); |
(...skipping 180 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
622 // User sets rotation to the same rotation that the display was at when | 592 // User sets rotation to the same rotation that the display was at when |
623 // maximize mode was activated. | 593 // maximize mode was activated. |
624 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 594 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
625 // Exit maximize mode | 595 // Exit maximize mode |
626 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 596 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
627 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 597 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
628 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 598 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
629 } | 599 } |
630 | 600 |
631 } // namespace ash | 601 } // namespace ash |
OLD | NEW |