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" |
11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
12 #include "ash/test/display_manager_test_api.h" | 12 #include "ash/test/display_manager_test_api.h" |
13 #include "ash/test/test_lock_state_controller_delegate.h" | |
14 #include "ash/test/test_screenshot_delegate.h" | |
15 #include "ash/test/test_system_tray_delegate.h" | 13 #include "ash/test/test_system_tray_delegate.h" |
16 #include "ash/test/test_volume_control_delegate.h" | 14 #include "ash/test/test_volume_control_delegate.h" |
17 #include "ash/wm/maximize_mode/internal_input_device_list.h" | 15 #include "ash/wm/maximize_mode/internal_input_device_list.h" |
18 #include "ash/wm/maximize_mode/maximize_mode_event_blocker.h" | 16 #include "ash/wm/maximize_mode/maximize_mode_event_blocker.h" |
19 #include "ui/aura/test/event_generator.h" | 17 #include "ui/aura/test/event_generator.h" |
20 #include "ui/events/event_handler.h" | 18 #include "ui/events/event_handler.h" |
21 #include "ui/gfx/vector3d_f.h" | 19 #include "ui/gfx/vector3d_f.h" |
22 #include "ui/message_center/message_center.h" | 20 #include "ui/message_center/message_center.h" |
23 | 21 |
24 #if defined(USE_X11) | 22 #if defined(USE_X11) |
(...skipping 360 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
385 // Lid open 90 degrees. | 383 // Lid open 90 degrees. |
386 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 384 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
387 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 385 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
388 | 386 |
389 event_generator.PressKey(ui::VKEY_ESCAPE, 0); | 387 event_generator.PressKey(ui::VKEY_ESCAPE, 0); |
390 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0); | 388 event_generator.ReleaseKey(ui::VKEY_ESCAPE, 0); |
391 EXPECT_GT(counter.event_count(), 0u); | 389 EXPECT_GT(counter.event_count(), 0u); |
392 counter.reset(); | 390 counter.reset(); |
393 } | 391 } |
394 | 392 |
395 #if defined(OS_CHROMEOS) | |
396 // Tests that a screenshot can be taken in maximize mode by holding volume down | |
397 // and pressing power. | |
398 TEST_F(MaximizeModeControllerTest, Screenshot) { | |
399 Shell::GetInstance()->lock_state_controller()->SetDelegate( | |
400 new test::TestLockStateControllerDelegate); | |
401 aura::Window* root = Shell::GetPrimaryRootWindow(); | |
402 aura::test::EventGenerator event_generator(root, root); | |
403 test::TestScreenshotDelegate* delegate = GetScreenshotDelegate(); | |
404 delegate->set_can_take_screenshot(true); | |
405 | |
406 // Open up 270 degrees. | |
407 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | |
408 gfx::Vector3dF(1.0f, 0.0f, 0.0f)); | |
409 ASSERT_TRUE(IsMaximizeModeStarted()); | |
410 | |
411 // Pressing power alone does not take a screenshot. | |
412 event_generator.PressKey(ui::VKEY_POWER, 0); | |
413 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | |
414 EXPECT_EQ(0, delegate->handle_take_screenshot_count()); | |
415 | |
416 // Holding volume down and pressing power takes a screenshot. | |
417 event_generator.PressKey(ui::VKEY_VOLUME_DOWN, 0); | |
418 event_generator.PressKey(ui::VKEY_POWER, 0); | |
419 event_generator.ReleaseKey(ui::VKEY_POWER, 0); | |
420 EXPECT_EQ(1, delegate->handle_take_screenshot_count()); | |
421 event_generator.ReleaseKey(ui::VKEY_VOLUME_DOWN, 0); | |
422 } | |
423 #endif // OS_CHROMEOS | |
424 | |
425 #if defined(USE_X11) | 393 #if defined(USE_X11) |
426 // Tests that maximize mode allows volume up/down events originating | 394 // Tests that maximize mode allows volume up/down events originating |
427 // from dedicated buttons versus remapped keyboard buttons. | 395 // from dedicated buttons versus remapped keyboard buttons. |
428 TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) { | 396 TEST_F(MaximizeModeControllerTest, AllowsVolumeControl) { |
429 aura::Window* root = Shell::GetPrimaryRootWindow(); | 397 aura::Window* root = Shell::GetPrimaryRootWindow(); |
430 aura::test::EventGenerator event_generator(root, root); | 398 aura::test::EventGenerator event_generator(root, root); |
431 | 399 |
432 TestVolumeControlDelegate* volume_delegate = | 400 TestVolumeControlDelegate* volume_delegate = |
433 new TestVolumeControlDelegate(true); | 401 new TestVolumeControlDelegate(true); |
434 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( | 402 ash::Shell::GetInstance()->system_tray_delegate()->SetVolumeControlDelegate( |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
670 // 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 |
671 // maximize mode was activated. | 639 // maximize mode was activated. |
672 SetInternalDisplayRotation(gfx::Display::ROTATE_0); | 640 SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
673 // Exit maximize mode | 641 // Exit maximize mode |
674 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), | 642 TriggerAccelerometerUpdate(gfx::Vector3dF(0.0f, 0.0f, 1.0f), |
675 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); | 643 gfx::Vector3dF(-1.0f, 0.0f, 0.0f)); |
676 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); | 644 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
677 } | 645 } |
678 | 646 |
679 } // namespace ash | 647 } // namespace ash |
OLD | NEW |