| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/lock_state_controller.h" | 5 #include "ash/wm/lock_state_controller.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/session_state_delegate.h" | 8 #include "ash/session_state_delegate.h" |
| 9 #include "ash/shell.h" | 9 #include "ash/shell.h" |
| 10 #include "ash/shell_window_ids.h" | 10 #include "ash/shell_window_ids.h" |
| 11 #include "ash/test/ash_test_base.h" | 11 #include "ash/test/ash_test_base.h" |
| 12 #include "ash/test/test_shell_delegate.h" | 12 #include "ash/test/test_shell_delegate.h" |
| 13 #include "ash/wm/power_button_controller.h" | 13 #include "ash/wm/power_button_controller.h" |
| 14 #include "ash/wm/session_state_animator.h" | 14 #include "ash/wm/session_state_animator.h" |
| 15 #include "base/command_line.h" | 15 #include "base/command_line.h" |
| 16 #include "base/memory/scoped_ptr.h" | 16 #include "base/memory/scoped_ptr.h" |
| 17 #include "base/time/time.h" | 17 #include "base/time/time.h" |
| 18 #include "ui/aura/env.h" | 18 #include "ui/aura/env.h" |
| 19 #include "ui/aura/test/event_generator.h" | 19 #include "ui/aura/test/event_generator.h" |
| 20 #include "ui/aura/test/test_window_delegate.h" | 20 #include "ui/aura/test/test_window_delegate.h" |
| 21 #include "ui/aura/window_event_dispatcher.h" | 21 #include "ui/aura/window_event_dispatcher.h" |
| 22 #include "ui/compositor/layer_animator.h" | 22 #include "ui/compositor/layer_animator.h" |
| 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" | 23 #include "ui/compositor/scoped_animation_duration_scale_mode.h" |
| 24 #include "ui/compositor/scoped_layer_animation_settings.h" | 24 #include "ui/compositor/scoped_layer_animation_settings.h" |
| 25 #include "ui/gfx/rect.h" | 25 #include "ui/gfx/rect.h" |
| 26 #include "ui/gfx/size.h" | 26 #include "ui/gfx/size.h" |
| 27 | 27 |
| 28 #if defined(OS_CHROMEOS) && defined(USE_X11) | 28 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 29 #include "ui/display/chromeos/output_configurator.h" | 29 #include "ui/display/chromeos/output_configurator.h" |
| 30 #include "ui/display/chromeos/test/test_display_snapshot.h" |
| 30 #include "ui/display/display_constants.h" | 31 #include "ui/display/display_constants.h" |
| 31 #endif | 32 #endif |
| 32 | 33 |
| 33 #if defined(OS_WIN) | 34 #if defined(OS_WIN) |
| 34 #include "base/win/windows_version.h" | 35 #include "base/win/windows_version.h" |
| 35 #endif | 36 #endif |
| 36 | 37 |
| 37 namespace ash { | 38 namespace ash { |
| 38 | 39 |
| 39 using internal::SessionStateAnimator; | 40 using internal::SessionStateAnimator; |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 991 // After increasing the brightness to 10%, we should start the timer like | 992 // After increasing the brightness to 10%, we should start the timer like |
| 992 // usual. | 993 // usual. |
| 993 controller_->OnScreenBrightnessChanged(10.0); | 994 controller_->OnScreenBrightnessChanged(10.0); |
| 994 PressPowerButton(); | 995 PressPowerButton(); |
| 995 EXPECT_TRUE(test_api_->is_animating_lock()); | 996 EXPECT_TRUE(test_api_->is_animating_lock()); |
| 996 ReleasePowerButton(); | 997 ReleasePowerButton(); |
| 997 } | 998 } |
| 998 | 999 |
| 999 #if defined(OS_CHROMEOS) && defined(USE_X11) | 1000 #if defined(OS_CHROMEOS) && defined(USE_X11) |
| 1000 TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) { | 1001 TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) { |
| 1002 ScopedVector<const ui::DisplayMode> modes; |
| 1003 modes.push_back(new ui::DisplayMode(gfx::Size(1, 1), false, 60.0f)); |
| 1004 |
| 1001 // Create two outputs, the first internal and the second external. | 1005 // Create two outputs, the first internal and the second external. |
| 1002 std::vector<ui::OutputConfigurator::OutputSnapshot> outputs; | 1006 ui::OutputConfigurator::DisplayStateList outputs; |
| 1003 ui::OutputConfigurator::OutputSnapshot internal_output; | 1007 ui::OutputConfigurator::DisplayState internal_output; |
| 1004 internal_output.type = ui::OUTPUT_TYPE_INTERNAL; | 1008 ui::TestDisplaySnapshot internal_display; |
| 1009 internal_display.set_type(ui::OUTPUT_TYPE_INTERNAL); |
| 1010 internal_display.set_modes(modes.get()); |
| 1011 internal_output.display = &internal_display; |
| 1005 outputs.push_back(internal_output); | 1012 outputs.push_back(internal_output); |
| 1006 ui::OutputConfigurator::OutputSnapshot external_output; | 1013 |
| 1007 external_output.type = ui::OUTPUT_TYPE_HDMI; | 1014 ui::OutputConfigurator::DisplayState external_output; |
| 1015 ui::TestDisplaySnapshot external_display; |
| 1016 external_display.set_type(ui::OUTPUT_TYPE_HDMI); |
| 1017 external_display.set_modes(modes.get()); |
| 1018 external_output.display = &external_display; |
| 1008 outputs.push_back(external_output); | 1019 outputs.push_back(external_output); |
| 1009 | 1020 |
| 1010 // When all of the displays are turned off (e.g. due to user inactivity), the | 1021 // When all of the displays are turned off (e.g. due to user inactivity), the |
| 1011 // power button should be ignored. | 1022 // power button should be ignored. |
| 1012 controller_->OnScreenBrightnessChanged(0.0); | 1023 controller_->OnScreenBrightnessChanged(0.0); |
| 1013 outputs[0].current_mode = 0; | 1024 static_cast<ui::TestDisplaySnapshot*>(outputs[0].display) |
| 1014 outputs[1].current_mode = 0; | 1025 ->set_current_mode(NULL); |
| 1026 static_cast<ui::TestDisplaySnapshot*>(outputs[1].display) |
| 1027 ->set_current_mode(NULL); |
| 1015 controller_->OnDisplayModeChanged(outputs); | 1028 controller_->OnDisplayModeChanged(outputs); |
| 1016 PressPowerButton(); | 1029 PressPowerButton(); |
| 1017 EXPECT_FALSE(test_api_->is_animating_lock()); | 1030 EXPECT_FALSE(test_api_->is_animating_lock()); |
| 1018 ReleasePowerButton(); | 1031 ReleasePowerButton(); |
| 1019 | 1032 |
| 1020 // When the screen brightness is 0% but the external display is still turned | 1033 // When the screen brightness is 0% but the external display is still turned |
| 1021 // on (indicating either docked mode or the user having manually decreased the | 1034 // on (indicating either docked mode or the user having manually decreased the |
| 1022 // brightness to 0%), the power button should still be handled. | 1035 // brightness to 0%), the power button should still be handled. |
| 1023 outputs[1].current_mode = 1; | 1036 static_cast<ui::TestDisplaySnapshot*>(outputs[1].display) |
| 1037 ->set_current_mode(modes[0]); |
| 1024 controller_->OnDisplayModeChanged(outputs); | 1038 controller_->OnDisplayModeChanged(outputs); |
| 1025 PressPowerButton(); | 1039 PressPowerButton(); |
| 1026 EXPECT_TRUE(test_api_->is_animating_lock()); | 1040 EXPECT_TRUE(test_api_->is_animating_lock()); |
| 1027 ReleasePowerButton(); | 1041 ReleasePowerButton(); |
| 1028 } | 1042 } |
| 1029 #endif | 1043 #endif |
| 1030 | 1044 |
| 1031 // Test that hidden background appears and revers correctly on lock/cancel. | 1045 // Test that hidden background appears and revers correctly on lock/cancel. |
| 1032 // TODO(antrim): Reenable this: http://crbug.com/167048 | 1046 // TODO(antrim): Reenable this: http://crbug.com/167048 |
| 1033 TEST_F(LockStateControllerTest, DISABLED_TestHiddenBackgroundLockCancel) { | 1047 TEST_F(LockStateControllerTest, DISABLED_TestHiddenBackgroundLockCancel) { |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1102 | 1116 |
| 1103 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); | 1117 Advance(SessionStateAnimator::ANIMATION_SPEED_MOVE_WINDOWS); |
| 1104 ExpectUnlockAfterUIDestroyedAnimationFinished(); | 1118 ExpectUnlockAfterUIDestroyedAnimationFinished(); |
| 1105 EXPECT_TRUE(IsBackgroundHidden()); | 1119 EXPECT_TRUE(IsBackgroundHidden()); |
| 1106 | 1120 |
| 1107 ExpectUnlockedState(); | 1121 ExpectUnlockedState(); |
| 1108 } | 1122 } |
| 1109 | 1123 |
| 1110 } // namespace test | 1124 } // namespace test |
| 1111 } // namespace ash | 1125 } // namespace ash |
| OLD | NEW |