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

Side by Side Diff: ash/wm/lock_state_controller_unittest.cc

Issue 2407153008: Delete TestDisplaySnapshot and update tests. (Closed)
Patch Set: Rebase and cleanup. Created 4 years, 2 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
« no previous file with comments | « ash/display/projecting_observer_chromeos_unittest.cc ('k') | ui/display/BUILD.gn » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "ash/common/session/session_state_delegate.h" 10 #include "ash/common/session/session_state_delegate.h"
11 #include "ash/common/test/test_session_state_delegate.h" 11 #include "ash/common/test/test_session_state_delegate.h"
12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h" 12 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
13 #include "ash/common/wm_shell.h" 13 #include "ash/common/wm_shell.h"
14 #include "ash/shell.h" 14 #include "ash/shell.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/test/test_lock_state_controller_delegate.h" 16 #include "ash/test/test_lock_state_controller_delegate.h"
17 #include "ash/test/test_screenshot_delegate.h" 17 #include "ash/test/test_screenshot_delegate.h"
18 #include "ash/test/test_session_state_animator.h" 18 #include "ash/test/test_session_state_animator.h"
19 #include "ash/test/test_shell_delegate.h" 19 #include "ash/test/test_shell_delegate.h"
20 #include "ash/wm/power_button_controller.h" 20 #include "ash/wm/power_button_controller.h"
21 #include "ash/wm/session_state_animator.h" 21 #include "ash/wm/session_state_animator.h"
22 #include "base/memory/scoped_vector.h" 22 #include "base/memory/scoped_vector.h"
23 #include "base/time/time.h" 23 #include "base/time/time.h"
24 #include "chromeos/dbus/dbus_thread_manager.h" 24 #include "chromeos/dbus/dbus_thread_manager.h"
25 #include "chromeos/dbus/fake_session_manager_client.h" 25 #include "chromeos/dbus/fake_session_manager_client.h"
26 #include "ui/display/chromeos/display_configurator.h" 26 #include "ui/display/chromeos/display_configurator.h"
27 #include "ui/display/chromeos/test/test_display_snapshot.h" 27 #include "ui/display/fake_display_snapshot.h"
28 #include "ui/display/types/display_constants.h" 28 #include "ui/display/types/display_constants.h"
29 #include "ui/events/test/event_generator.h" 29 #include "ui/events/test/event_generator.h"
30 #include "ui/gfx/geometry/size.h" 30 #include "ui/gfx/geometry/size.h"
31 31
32 namespace ash { 32 namespace ash {
33 namespace test { 33 namespace test {
34 namespace { 34 namespace {
35 35
36 bool cursor_visible() { 36 bool cursor_visible() {
37 return Shell::GetInstance()->cursor_manager()->IsCursorVisible(); 37 return Shell::GetInstance()->cursor_manager()->IsCursorVisible();
(...skipping 842 matching lines...) Expand 10 before | Expand all | Expand 10 after
880 880
881 // After increasing the brightness to 10%, we should start the timer like 881 // After increasing the brightness to 10%, we should start the timer like
882 // usual. 882 // usual.
883 power_button_controller_->OnScreenBrightnessChanged(10.0); 883 power_button_controller_->OnScreenBrightnessChanged(10.0);
884 PressPowerButton(); 884 PressPowerButton();
885 EXPECT_TRUE(test_api_->is_animating_lock()); 885 EXPECT_TRUE(test_api_->is_animating_lock());
886 ReleasePowerButton(); 886 ReleasePowerButton();
887 } 887 }
888 888
889 TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) { 889 TEST_F(LockStateControllerTest, HonorPowerButtonInDockedMode) {
890 std::vector<std::unique_ptr<const ui::DisplayMode>> modes;
891 modes.push_back(
892 base::MakeUnique<ui::DisplayMode>(gfx::Size(1, 1), false, 60.0f));
893
894 // Create two outputs, the first internal and the second external. 890 // Create two outputs, the first internal and the second external.
895 ui::DisplayConfigurator::DisplayStateList outputs; 891 ui::DisplayConfigurator::DisplayStateList outputs;
896 ui::TestDisplaySnapshot internal_display;
897 internal_display.set_type(ui::DISPLAY_CONNECTION_TYPE_INTERNAL);
898 internal_display.set_modes(std::move(modes));
899 outputs.push_back(&internal_display);
900 892
901 modes.clear(); 893 std::unique_ptr<ui::DisplaySnapshot> internal_display =
902 modes.push_back( 894 display::FakeDisplaySnapshot::Builder()
903 base::MakeUnique<ui::DisplayMode>(gfx::Size(1, 1), false, 60.0f)); 895 .SetId(123)
904 ui::TestDisplaySnapshot external_display; 896 .SetNativeMode(gfx::Size(1, 1))
905 external_display.set_type(ui::DISPLAY_CONNECTION_TYPE_HDMI); 897 .SetType(ui::DISPLAY_CONNECTION_TYPE_INTERNAL)
906 external_display.set_modes(std::move(modes)); 898 .Build();
907 outputs.push_back(&external_display); 899 outputs.push_back(internal_display.get());
900
901 std::unique_ptr<ui::DisplaySnapshot> external_display =
902 display::FakeDisplaySnapshot::Builder()
903 .SetId(456)
904 .SetNativeMode(gfx::Size(1, 1))
905 .SetType(ui::DISPLAY_CONNECTION_TYPE_HDMI)
906 .Build();
907 outputs.push_back(external_display.get());
908 908
909 // When all of the displays are turned off (e.g. due to user inactivity), the 909 // When all of the displays are turned off (e.g. due to user inactivity), the
910 // power button should be ignored. 910 // power button should be ignored.
911 power_button_controller_->OnScreenBrightnessChanged(0.0); 911 power_button_controller_->OnScreenBrightnessChanged(0.0);
912 internal_display.set_current_mode(nullptr); 912 internal_display->set_current_mode(nullptr);
913 external_display.set_current_mode(nullptr); 913 external_display->set_current_mode(nullptr);
914 power_button_controller_->OnDisplayModeChanged(outputs); 914 power_button_controller_->OnDisplayModeChanged(outputs);
915 PressPowerButton(); 915 PressPowerButton();
916 EXPECT_FALSE(test_api_->is_animating_lock()); 916 EXPECT_FALSE(test_api_->is_animating_lock());
917 ReleasePowerButton(); 917 ReleasePowerButton();
918 918
919 // When the screen brightness is 0% but the external display is still turned 919 // When the screen brightness is 0% but the external display is still turned
920 // on (indicating either docked mode or the user having manually decreased the 920 // on (indicating either docked mode or the user having manually decreased the
921 // brightness to 0%), the power button should still be handled. 921 // brightness to 0%), the power button should still be handled.
922 external_display.set_current_mode(external_display.modes().back().get()); 922 external_display->set_current_mode(external_display->modes().back().get());
923 power_button_controller_->OnDisplayModeChanged(outputs); 923 power_button_controller_->OnDisplayModeChanged(outputs);
924 PressPowerButton(); 924 PressPowerButton();
925 EXPECT_TRUE(test_api_->is_animating_lock()); 925 EXPECT_TRUE(test_api_->is_animating_lock());
926 ReleasePowerButton(); 926 ReleasePowerButton();
927 } 927 }
928 928
929 // Test that hidden wallpaper appears and revers correctly on lock/cancel. 929 // Test that hidden wallpaper appears and revers correctly on lock/cancel.
930 TEST_F(LockStateControllerTest, TestHiddenWallpaperLockCancel) { 930 TEST_F(LockStateControllerTest, TestHiddenWallpaperLockCancel) {
931 Initialize(false, LoginStatus::USER); 931 Initialize(false, LoginStatus::USER);
932 HideWallpaper(); 932 HideWallpaper();
(...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after
1088 ReleasePowerButton(); 1088 ReleasePowerButton();
1089 1089
1090 ExpectPreLockAnimationStarted(); 1090 ExpectPreLockAnimationStarted();
1091 1091
1092 test_animator_->CompleteAllAnimations(true); 1092 test_animator_->CompleteAllAnimations(true);
1093 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count()); 1093 EXPECT_EQ(1, session_manager_client_->request_lock_screen_call_count());
1094 } 1094 }
1095 1095
1096 } // namespace test 1096 } // namespace test
1097 } // namespace ash 1097 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/projecting_observer_chromeos_unittest.cc ('k') | ui/display/BUILD.gn » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698