OLD | NEW |
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/mirror_window_test_api.h" | 19 #include "ash/test/mirror_window_test_api.h" |
20 #include "ash/test/screen_orientation_controller_test_api.h" | 20 #include "ash/test/screen_orientation_controller_test_api.h" |
21 #include "ash/wm/tablet_mode/tablet_mode_controller.h" | 21 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
22 #include "ash/wm/window_state.h" | 22 #include "ash/wm/window_state.h" |
23 #include "ash/wm/window_util.h" | 23 #include "ash/wm/window_util.h" |
24 #include "base/command_line.h" | 24 #include "base/command_line.h" |
25 #include "base/format_macros.h" | 25 #include "base/format_macros.h" |
26 #include "base/strings/string_number_conversions.h" | 26 #include "base/strings/string_number_conversions.h" |
27 #include "base/strings/stringprintf.h" | 27 #include "base/strings/stringprintf.h" |
28 #include "build/build_config.h" | 28 #include "build/build_config.h" |
29 #include "chromeos/accelerometer/accelerometer_reader.h" | 29 #include "chromeos/accelerometer/accelerometer_reader.h" |
30 #include "chromeos/accelerometer/accelerometer_types.h" | 30 #include "chromeos/accelerometer/accelerometer_types.h" |
31 #include "ui/aura/client/aura_constants.h" | 31 #include "ui/aura/client/aura_constants.h" |
(...skipping 2988 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
3020 // Rotate to portrait in clamshell. | 3020 // Rotate to portrait in clamshell. |
3021 configuration_controller->SetDisplayRotation( | 3021 configuration_controller->SetDisplayRotation( |
3022 screen->GetPrimaryDisplay().id(), display::Display::ROTATE_90, | 3022 screen->GetPrimaryDisplay().id(), display::Display::ROTATE_90, |
3023 display::Display::ROTATION_SOURCE_USER); | 3023 display::Display::ROTATION_SOURCE_USER); |
3024 EXPECT_EQ(display::Display::ROTATE_90, | 3024 EXPECT_EQ(display::Display::ROTATE_90, |
3025 screen->GetPrimaryDisplay().rotation()); | 3025 screen->GetPrimaryDisplay().rotation()); |
3026 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); | 3026 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); |
3027 | 3027 |
3028 EXPECT_EQ(0, test_observer.countAndReset()); | 3028 EXPECT_EQ(0, test_observer.countAndReset()); |
3029 // Just enabling will not save the lock. | 3029 // Just enabling will not save the lock. |
3030 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); | 3030 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 3031 true); |
3031 EXPECT_EQ(1, test_observer.countAndReset()); | 3032 EXPECT_EQ(1, test_observer.countAndReset()); |
3032 | 3033 |
3033 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); | 3034 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); |
3034 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); | 3035 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); |
3035 EXPECT_EQ(blink::kWebScreenOrientationLockLandscapePrimary, | 3036 EXPECT_EQ(blink::kWebScreenOrientationLockLandscapePrimary, |
3036 test_api.GetCurrentOrientation()); | 3037 test_api.GetCurrentOrientation()); |
3037 | 3038 |
3038 // Enable lock at 0. | 3039 // Enable lock at 0. |
3039 orientation_controller->ToggleUserRotationLock(); | 3040 orientation_controller->ToggleUserRotationLock(); |
3040 EXPECT_EQ(1, test_observer.countAndReset()); | 3041 EXPECT_EQ(1, test_observer.countAndReset()); |
(...skipping 21 matching lines...) Expand all Loading... |
3062 EXPECT_EQ(0, test_observer.countAndReset()); | 3063 EXPECT_EQ(0, test_observer.countAndReset()); |
3063 | 3064 |
3064 wm::ActivateWindow(window_l); | 3065 wm::ActivateWindow(window_l); |
3065 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); | 3066 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); |
3066 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock()); | 3067 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock()); |
3067 EXPECT_EQ(display::Display::ROTATE_0, | 3068 EXPECT_EQ(display::Display::ROTATE_0, |
3068 display_manager->registered_internal_display_rotation()); | 3069 display_manager->registered_internal_display_rotation()); |
3069 EXPECT_EQ(0, test_observer.countAndReset()); | 3070 EXPECT_EQ(0, test_observer.countAndReset()); |
3070 | 3071 |
3071 // Exit tablet mode reset to clamshell's rotation, which is 90. | 3072 // Exit tablet mode reset to clamshell's rotation, which is 90. |
3072 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false); | 3073 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 3074 false); |
3073 EXPECT_EQ(1, test_observer.countAndReset()); | 3075 EXPECT_EQ(1, test_observer.countAndReset()); |
3074 EXPECT_EQ(display::Display::ROTATE_90, | 3076 EXPECT_EQ(display::Display::ROTATE_90, |
3075 screen->GetPrimaryDisplay().rotation()); | 3077 screen->GetPrimaryDisplay().rotation()); |
3076 // Activate Any. | 3078 // Activate Any. |
3077 wm::ActivateWindow(window_a); | 3079 wm::ActivateWindow(window_a); |
3078 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); | 3080 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 3081 true); |
3079 EXPECT_EQ(1, test_observer.countAndReset()); | 3082 EXPECT_EQ(1, test_observer.countAndReset()); |
3080 // Entering with active ANY will lock again to landscape. | 3083 // Entering with active ANY will lock again to landscape. |
3081 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); | 3084 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); |
3082 | 3085 |
3083 wm::ActivateWindow(window_p); | 3086 wm::ActivateWindow(window_p); |
3084 EXPECT_EQ(display::Display::ROTATE_90, | 3087 EXPECT_EQ(display::Display::ROTATE_90, |
3085 screen->GetPrimaryDisplay().rotation()); | 3088 screen->GetPrimaryDisplay().rotation()); |
3086 EXPECT_EQ(0, test_observer.countAndReset()); | 3089 EXPECT_EQ(0, test_observer.countAndReset()); |
3087 orientation_controller->ToggleUserRotationLock(); | 3090 orientation_controller->ToggleUserRotationLock(); |
3088 orientation_controller->ToggleUserRotationLock(); | 3091 orientation_controller->ToggleUserRotationLock(); |
(...skipping 24 matching lines...) Expand all Loading... |
3113 ScreenOrientationController* orientation_controller = | 3116 ScreenOrientationController* orientation_controller = |
3114 shell->screen_orientation_controller(); | 3117 shell->screen_orientation_controller(); |
3115 | 3118 |
3116 // Set up windows with portrait,lanscape and any. | 3119 // Set up windows with portrait,lanscape and any. |
3117 aura::Window* window = CreateTestWindowInShellWithId(0); | 3120 aura::Window* window = CreateTestWindowInShellWithId(0); |
3118 window->SetProperty(aura::client::kAppType, | 3121 window->SetProperty(aura::client::kAppType, |
3119 static_cast<int>(AppType::CHROME_APP)); | 3122 static_cast<int>(AppType::CHROME_APP)); |
3120 display::Screen* screen = display::Screen::GetScreen(); | 3123 display::Screen* screen = display::Screen::GetScreen(); |
3121 | 3124 |
3122 // Just enabling will not save the lock. | 3125 // Just enabling will not save the lock. |
3123 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); | 3126 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 3127 true); |
3124 | 3128 |
3125 orientation_controller->LockOrientationForWindow( | 3129 orientation_controller->LockOrientationForWindow( |
3126 window, blink::kWebScreenOrientationLockPortrait, | 3130 window, blink::kWebScreenOrientationLockPortrait, |
3127 ScreenOrientationController::LockCompletionBehavior::None); | 3131 ScreenOrientationController::LockCompletionBehavior::None); |
3128 EXPECT_EQ(display::Display::ROTATE_90, | 3132 EXPECT_EQ(display::Display::ROTATE_90, |
3129 screen->GetPrimaryDisplay().rotation()); | 3133 screen->GetPrimaryDisplay().rotation()); |
3130 | 3134 |
3131 orientation_controller->OnAccelerometerUpdated(portrait_secondary); | 3135 orientation_controller->OnAccelerometerUpdated(portrait_secondary); |
3132 | 3136 |
3133 EXPECT_EQ(display::Display::ROTATE_270, | 3137 EXPECT_EQ(display::Display::ROTATE_270, |
(...skipping 26 matching lines...) Expand all Loading... |
3160 | 3164 |
3161 aura::Window* window_a = CreateTestWindowInShellWithId(0); | 3165 aura::Window* window_a = CreateTestWindowInShellWithId(0); |
3162 { | 3166 { |
3163 window_a->SetProperty(aura::client::kAppType, | 3167 window_a->SetProperty(aura::client::kAppType, |
3164 static_cast<int>(AppType::CHROME_APP)); | 3168 static_cast<int>(AppType::CHROME_APP)); |
3165 orientation_controller->LockOrientationForWindow( | 3169 orientation_controller->LockOrientationForWindow( |
3166 window_a, blink::kWebScreenOrientationLockAny, | 3170 window_a, blink::kWebScreenOrientationLockAny, |
3167 ScreenOrientationController::LockCompletionBehavior::None); | 3171 ScreenOrientationController::LockCompletionBehavior::None); |
3168 } | 3172 } |
3169 wm::ActivateWindow(window_a); | 3173 wm::ActivateWindow(window_a); |
3170 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true); | 3174 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( |
| 3175 true); |
3171 | 3176 |
3172 orientation_controller->OnAccelerometerUpdated(portrait_primary); | 3177 orientation_controller->OnAccelerometerUpdated(portrait_primary); |
3173 | 3178 |
3174 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary, | 3179 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary, |
3175 test_api.GetCurrentOrientation()); | 3180 test_api.GetCurrentOrientation()); |
3176 | 3181 |
3177 orientation_controller->OnAccelerometerUpdated(portrait_secondary); | 3182 orientation_controller->OnAccelerometerUpdated(portrait_secondary); |
3178 | 3183 |
3179 aura::Window* window_ps = CreateTestWindowInShellWithId(1); | 3184 aura::Window* window_ps = CreateTestWindowInShellWithId(1); |
3180 { | 3185 { |
(...skipping 21 matching lines...) Expand all Loading... |
3202 test_api.GetCurrentOrientation()); | 3207 test_api.GetCurrentOrientation()); |
3203 | 3208 |
3204 // The orientation has alraedy been locked to secondary once, so | 3209 // The orientation has alraedy been locked to secondary once, so |
3205 // it should swtich back to the portrait secondary. | 3210 // it should swtich back to the portrait secondary. |
3206 wm::ActivateWindow(window_ps); | 3211 wm::ActivateWindow(window_ps); |
3207 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, | 3212 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, |
3208 test_api.GetCurrentOrientation()); | 3213 test_api.GetCurrentOrientation()); |
3209 } | 3214 } |
3210 | 3215 |
3211 } // namespace ash | 3216 } // namespace ash |
OLD | NEW |