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

Side by Side Diff: ash/display/display_manager_unittest.cc

Issue 2837773003: Flip the flag to enable smooth screen rotation by default. (Closed)
Patch Set: Created 3 years, 8 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/display_configuration_controller.cc ('k') | ash/rotator/screen_rotation_animator.h » ('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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 "ui/display/manager/display_manager.h" 5 #include "ui/display/manager/display_manager.h"
6 6
7 #include "ash/accelerators/accelerator_commands_aura.h" 7 #include "ash/accelerators/accelerator_commands_aura.h"
8 #include "ash/ash_switches.h" 8 #include "ash/ash_switches.h"
9 #include "ash/display/display_configuration_controller.h" 9 #include "ash/display/display_configuration_controller.h"
10 #include "ash/display/display_util.h" 10 #include "ash/display/display_util.h"
11 #include "ash/display/mirror_window_controller.h" 11 #include "ash/display/mirror_window_controller.h"
12 #include "ash/display/screen_orientation_controller_chromeos.h" 12 #include "ash/display/screen_orientation_controller_chromeos.h"
13 #include "ash/display/window_tree_host_manager.h" 13 #include "ash/display/window_tree_host_manager.h"
14 #include "ash/screen_util.h" 14 #include "ash/screen_util.h"
15 #include "ash/shared/app_types.h" 15 #include "ash/shared/app_types.h"
16 #include "ash/shell.h" 16 #include "ash/shell.h"
17 #include "ash/strings/grit/ash_strings.h" 17 #include "ash/strings/grit/ash_strings.h"
18 #include "ash/test/ash_test_base.h" 18 #include "ash/test/ash_test_base.h"
19 #include "ash/test/display_configuration_controller_test_api.h"
19 #include "ash/test/mirror_window_test_api.h" 20 #include "ash/test/mirror_window_test_api.h"
20 #include "ash/test/screen_orientation_controller_test_api.h" 21 #include "ash/test/screen_orientation_controller_test_api.h"
21 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 22 #include "ash/wm/maximize_mode/maximize_mode_controller.h"
22 #include "ash/wm/window_state.h" 23 #include "ash/wm/window_state.h"
23 #include "ash/wm/window_state_aura.h" 24 #include "ash/wm/window_state_aura.h"
24 #include "ash/wm/window_util.h" 25 #include "ash/wm/window_util.h"
25 #include "ash/wm_window.h" 26 #include "ash/wm_window.h"
26 #include "base/command_line.h" 27 #include "base/command_line.h"
27 #include "base/format_macros.h" 28 #include "base/format_macros.h"
28 #include "base/strings/string_number_conversions.h" 29 #include "base/strings/string_number_conversions.h"
(...skipping 2982 matching lines...) Expand 10 before | Expand all | Expand 10 after
3011 WmWindow* wm_window_l = WmWindow::Get(window_l); 3012 WmWindow* wm_window_l = WmWindow::Get(window_l);
3012 wm_window_l->SetAppType(static_cast<int>(AppType::CHROME_APP)); 3013 wm_window_l->SetAppType(static_cast<int>(AppType::CHROME_APP));
3013 orientation_controller->LockOrientationForWindow( 3014 orientation_controller->LockOrientationForWindow(
3014 wm_window_l, blink::kWebScreenOrientationLockLandscape, 3015 wm_window_l, blink::kWebScreenOrientationLockLandscape,
3015 ScreenOrientationController::LockCompletionBehavior::None); 3016 ScreenOrientationController::LockCompletionBehavior::None);
3016 } 3017 }
3017 3018
3018 DisplayConfigurationController* configuration_controller = 3019 DisplayConfigurationController* configuration_controller =
3019 shell->display_configuration_controller(); 3020 shell->display_configuration_controller();
3020 display::Screen* screen = display::Screen::GetScreen(); 3021 display::Screen* screen = display::Screen::GetScreen();
3022 test::DisplayConfigurationControllerTestApi display_config_controller_testapi(
3023 configuration_controller);
3024 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3025 screen->GetPrimaryDisplay().id(), false);
3021 3026
3022 // Rotate to portrait in clamshell. 3027 // Rotate to portrait in clamshell.
3023 configuration_controller->SetDisplayRotation( 3028 configuration_controller->SetDisplayRotation(
3024 screen->GetPrimaryDisplay().id(), display::Display::ROTATE_90, 3029 screen->GetPrimaryDisplay().id(), display::Display::ROTATE_90,
3025 display::Display::ROTATION_SOURCE_USER); 3030 display::Display::ROTATION_SOURCE_USER);
3026 EXPECT_EQ(display::Display::ROTATE_90, 3031 EXPECT_EQ(display::Display::ROTATE_90,
3027 screen->GetPrimaryDisplay().rotation()); 3032 screen->GetPrimaryDisplay().rotation());
3028 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); 3033 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock());
3029 3034
3030 EXPECT_EQ(0, test_observer.countAndReset()); 3035 EXPECT_EQ(0, test_observer.countAndReset());
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
3101 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); 3106 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation());
3102 EXPECT_EQ(display::Display::ROTATE_90, 3107 EXPECT_EQ(display::Display::ROTATE_90,
3103 display_manager->registered_internal_display_rotation()); 3108 display_manager->registered_internal_display_rotation());
3104 3109
3105 // ANY will rotate to locked ortation. 3110 // ANY will rotate to locked ortation.
3106 wm::ActivateWindow(window_a); 3111 wm::ActivateWindow(window_a);
3107 EXPECT_EQ(display::Display::ROTATE_90, 3112 EXPECT_EQ(display::Display::ROTATE_90,
3108 screen->GetPrimaryDisplay().rotation()); 3113 screen->GetPrimaryDisplay().rotation());
3109 3114
3110 orientation_controller->RemoveObserver(&test_observer); 3115 orientation_controller->RemoveObserver(&test_observer);
3116 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3117 screen->GetPrimaryDisplay().id(), true);
oshima 2017/04/25 17:52:18 is this necessary?
3111 } 3118 }
3112 3119
3113 TEST_F(DisplayManagerOrientationTest, UserRotationLockReverse) { 3120 TEST_F(DisplayManagerOrientationTest, UserRotationLockReverse) {
3114 Shell* shell = Shell::Get(); 3121 Shell* shell = Shell::Get();
3115 display::DisplayManager* display_manager = shell->display_manager(); 3122 display::DisplayManager* display_manager = shell->display_manager();
3116 display::test::DisplayManagerTestApi test_api(display_manager); 3123 display::test::DisplayManagerTestApi test_api(display_manager);
3117 test_api.SetFirstDisplayAsInternalDisplay(); 3124 test_api.SetFirstDisplayAsInternalDisplay();
3118 ScreenOrientationController* orientation_controller = 3125 ScreenOrientationController* orientation_controller =
3119 shell->screen_orientation_controller(); 3126 shell->screen_orientation_controller();
3120 3127
3121 // Set up windows with portrait,lanscape and any. 3128 // Set up windows with portrait,lanscape and any.
3122 aura::Window* window = CreateTestWindowInShellWithId(0); 3129 aura::Window* window = CreateTestWindowInShellWithId(0);
3123 WmWindow* wm_window = WmWindow::Get(window); 3130 WmWindow* wm_window = WmWindow::Get(window);
3124 wm_window->SetAppType(static_cast<int>(AppType::CHROME_APP)); 3131 wm_window->SetAppType(static_cast<int>(AppType::CHROME_APP));
3125 display::Screen* screen = display::Screen::GetScreen(); 3132 display::Screen* screen = display::Screen::GetScreen();
3133 test::DisplayConfigurationControllerTestApi display_config_controller_testapi(
3134 shell->display_configuration_controller());
3135 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3136 screen->GetPrimaryDisplay().id(), false);
3126 3137
3127 // Just enabling will not save the lock. 3138 // Just enabling will not save the lock.
3128 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3139 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
3129 true); 3140 true);
3130 3141
3131 orientation_controller->LockOrientationForWindow( 3142 orientation_controller->LockOrientationForWindow(
3132 wm_window, blink::kWebScreenOrientationLockPortrait, 3143 wm_window, blink::kWebScreenOrientationLockPortrait,
3133 ScreenOrientationController::LockCompletionBehavior::None); 3144 ScreenOrientationController::LockCompletionBehavior::None);
3134 EXPECT_EQ(display::Display::ROTATE_90, 3145 EXPECT_EQ(display::Display::ROTATE_90,
3135 screen->GetPrimaryDisplay().rotation()); 3146 screen->GetPrimaryDisplay().rotation());
(...skipping 10 matching lines...) Expand all
3146 // Enable lock at 90. 3157 // Enable lock at 90.
3147 orientation_controller->ToggleUserRotationLock(); 3158 orientation_controller->ToggleUserRotationLock();
3148 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock()); 3159 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock());
3149 EXPECT_EQ(display::Display::ROTATE_90, 3160 EXPECT_EQ(display::Display::ROTATE_90,
3150 display_manager->registered_internal_display_rotation()); 3161 display_manager->registered_internal_display_rotation());
3151 3162
3152 orientation_controller->OnAccelerometerUpdated(portrait_secondary); 3163 orientation_controller->OnAccelerometerUpdated(portrait_secondary);
3153 3164
3154 EXPECT_EQ(display::Display::ROTATE_90, 3165 EXPECT_EQ(display::Display::ROTATE_90,
3155 screen->GetPrimaryDisplay().rotation()); 3166 screen->GetPrimaryDisplay().rotation());
3167
3168 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3169 screen->GetPrimaryDisplay().id(), true);
3156 } 3170 }
3157 3171
3158 TEST_F(DisplayManagerOrientationTest, LockToSpecificOrientation) { 3172 TEST_F(DisplayManagerOrientationTest, LockToSpecificOrientation) {
3159 Shell* shell = Shell::Get(); 3173 Shell* shell = Shell::Get();
3160 display::DisplayManager* display_manager = shell->display_manager(); 3174 display::DisplayManager* display_manager = shell->display_manager();
3161 display::test::DisplayManagerTestApi(display_manager) 3175 display::test::DisplayManagerTestApi(display_manager)
3162 .SetFirstDisplayAsInternalDisplay(); 3176 .SetFirstDisplayAsInternalDisplay();
3177 test::DisplayConfigurationControllerTestApi display_config_controller_testapi(
3178 Shell::Get()->display_configuration_controller());
3179 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3180 display_manager->GetDisplayAt(0).id(), false);
3163 ScreenOrientationController* orientation_controller = 3181 ScreenOrientationController* orientation_controller =
3164 shell->screen_orientation_controller(); 3182 shell->screen_orientation_controller();
3165 test::ScreenOrientationControllerTestApi test_api(orientation_controller); 3183 test::ScreenOrientationControllerTestApi test_api(orientation_controller);
3166 3184
3167 aura::Window* window_a = CreateTestWindowInShellWithId(0); 3185 aura::Window* window_a = CreateTestWindowInShellWithId(0);
3168 { 3186 {
3169 WmWindow* wm_window_a = WmWindow::Get(window_a); 3187 WmWindow* wm_window_a = WmWindow::Get(window_a);
3170 wm_window_a->SetAppType(static_cast<int>(AppType::CHROME_APP)); 3188 wm_window_a->SetAppType(static_cast<int>(AppType::CHROME_APP));
3171 orientation_controller->LockOrientationForWindow( 3189 orientation_controller->LockOrientationForWindow(
3172 wm_window_a, blink::kWebScreenOrientationLockAny, 3190 wm_window_a, blink::kWebScreenOrientationLockAny,
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
3206 3224
3207 // Swtching to |window_a| enables rotation. 3225 // Swtching to |window_a| enables rotation.
3208 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary, 3226 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary,
3209 test_api.GetCurrentOrientation()); 3227 test_api.GetCurrentOrientation());
3210 3228
3211 // The orientation has alraedy been locked to secondary once, so 3229 // The orientation has alraedy been locked to secondary once, so
3212 // it should swtich back to the portrait secondary. 3230 // it should swtich back to the portrait secondary.
3213 wm::ActivateWindow(window_ps); 3231 wm::ActivateWindow(window_ps);
3214 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, 3232 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary,
3215 test_api.GetCurrentOrientation()); 3233 test_api.GetCurrentOrientation());
3234 display_config_controller_testapi.SetEnableScreenRotationAnimator(
3235 display_manager->GetDisplayAt(0).id(), true);
3216 } 3236 }
3217 3237
3218 } // namespace ash 3238 } // namespace ash
OLDNEW
« no previous file with comments | « ash/display/display_configuration_controller.cc ('k') | ash/rotator/screen_rotation_animator.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698