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

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

Issue 2906803002: Rename MaximizeMode to TabletMode (Closed)
Patch Set: updated filter Created 3 years, 7 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
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/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/maximize_mode/maximize_mode_controller.h" 21 #include "ash/wm/tablet_mode/tablet_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
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()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3030 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
3031 true);
3032 EXPECT_EQ(1, test_observer.countAndReset()); 3031 EXPECT_EQ(1, test_observer.countAndReset());
3033 3032
3034 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); 3033 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation());
3035 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock()); 3034 EXPECT_FALSE(display_manager->registered_internal_display_rotation_lock());
3036 EXPECT_EQ(blink::kWebScreenOrientationLockLandscapePrimary, 3035 EXPECT_EQ(blink::kWebScreenOrientationLockLandscapePrimary,
3037 test_api.GetCurrentOrientation()); 3036 test_api.GetCurrentOrientation());
3038 3037
3039 // Enable lock at 0. 3038 // Enable lock at 0.
3040 orientation_controller->ToggleUserRotationLock(); 3039 orientation_controller->ToggleUserRotationLock();
3041 EXPECT_EQ(1, test_observer.countAndReset()); 3040 EXPECT_EQ(1, test_observer.countAndReset());
(...skipping 21 matching lines...) Expand all
3063 EXPECT_EQ(0, test_observer.countAndReset()); 3062 EXPECT_EQ(0, test_observer.countAndReset());
3064 3063
3065 wm::ActivateWindow(window_l); 3064 wm::ActivateWindow(window_l);
3066 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); 3065 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation());
3067 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock()); 3066 EXPECT_TRUE(display_manager->registered_internal_display_rotation_lock());
3068 EXPECT_EQ(display::Display::ROTATE_0, 3067 EXPECT_EQ(display::Display::ROTATE_0,
3069 display_manager->registered_internal_display_rotation()); 3068 display_manager->registered_internal_display_rotation());
3070 EXPECT_EQ(0, test_observer.countAndReset()); 3069 EXPECT_EQ(0, test_observer.countAndReset());
3071 3070
3072 // Exit tablet mode reset to clamshell's rotation, which is 90. 3071 // Exit tablet mode reset to clamshell's rotation, which is 90.
3073 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3072 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
3074 false);
3075 EXPECT_EQ(1, test_observer.countAndReset()); 3073 EXPECT_EQ(1, test_observer.countAndReset());
3076 EXPECT_EQ(display::Display::ROTATE_90, 3074 EXPECT_EQ(display::Display::ROTATE_90,
3077 screen->GetPrimaryDisplay().rotation()); 3075 screen->GetPrimaryDisplay().rotation());
3078 // Activate Any. 3076 // Activate Any.
3079 wm::ActivateWindow(window_a); 3077 wm::ActivateWindow(window_a);
3080 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3078 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
3081 true);
3082 EXPECT_EQ(1, test_observer.countAndReset()); 3079 EXPECT_EQ(1, test_observer.countAndReset());
3083 // Entering with active ANY will lock again to landscape. 3080 // Entering with active ANY will lock again to landscape.
3084 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation()); 3081 EXPECT_EQ(display::Display::ROTATE_0, screen->GetPrimaryDisplay().rotation());
3085 3082
3086 wm::ActivateWindow(window_p); 3083 wm::ActivateWindow(window_p);
3087 EXPECT_EQ(display::Display::ROTATE_90, 3084 EXPECT_EQ(display::Display::ROTATE_90,
3088 screen->GetPrimaryDisplay().rotation()); 3085 screen->GetPrimaryDisplay().rotation());
3089 EXPECT_EQ(0, test_observer.countAndReset()); 3086 EXPECT_EQ(0, test_observer.countAndReset());
3090 orientation_controller->ToggleUserRotationLock(); 3087 orientation_controller->ToggleUserRotationLock();
3091 orientation_controller->ToggleUserRotationLock(); 3088 orientation_controller->ToggleUserRotationLock();
(...skipping 24 matching lines...) Expand all
3116 ScreenOrientationController* orientation_controller = 3113 ScreenOrientationController* orientation_controller =
3117 shell->screen_orientation_controller(); 3114 shell->screen_orientation_controller();
3118 3115
3119 // Set up windows with portrait,lanscape and any. 3116 // Set up windows with portrait,lanscape and any.
3120 aura::Window* window = CreateTestWindowInShellWithId(0); 3117 aura::Window* window = CreateTestWindowInShellWithId(0);
3121 window->SetProperty(aura::client::kAppType, 3118 window->SetProperty(aura::client::kAppType,
3122 static_cast<int>(AppType::CHROME_APP)); 3119 static_cast<int>(AppType::CHROME_APP));
3123 display::Screen* screen = display::Screen::GetScreen(); 3120 display::Screen* screen = display::Screen::GetScreen();
3124 3121
3125 // Just enabling will not save the lock. 3122 // Just enabling will not save the lock.
3126 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3123 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
3127 true);
3128 3124
3129 orientation_controller->LockOrientationForWindow( 3125 orientation_controller->LockOrientationForWindow(
3130 window, blink::kWebScreenOrientationLockPortrait, 3126 window, blink::kWebScreenOrientationLockPortrait,
3131 ScreenOrientationController::LockCompletionBehavior::None); 3127 ScreenOrientationController::LockCompletionBehavior::None);
3132 EXPECT_EQ(display::Display::ROTATE_90, 3128 EXPECT_EQ(display::Display::ROTATE_90,
3133 screen->GetPrimaryDisplay().rotation()); 3129 screen->GetPrimaryDisplay().rotation());
3134 3130
3135 orientation_controller->OnAccelerometerUpdated(portrait_secondary); 3131 orientation_controller->OnAccelerometerUpdated(portrait_secondary);
3136 3132
3137 EXPECT_EQ(display::Display::ROTATE_270, 3133 EXPECT_EQ(display::Display::ROTATE_270,
(...skipping 26 matching lines...) Expand all
3164 3160
3165 aura::Window* window_a = CreateTestWindowInShellWithId(0); 3161 aura::Window* window_a = CreateTestWindowInShellWithId(0);
3166 { 3162 {
3167 window_a->SetProperty(aura::client::kAppType, 3163 window_a->SetProperty(aura::client::kAppType,
3168 static_cast<int>(AppType::CHROME_APP)); 3164 static_cast<int>(AppType::CHROME_APP));
3169 orientation_controller->LockOrientationForWindow( 3165 orientation_controller->LockOrientationForWindow(
3170 window_a, blink::kWebScreenOrientationLockAny, 3166 window_a, blink::kWebScreenOrientationLockAny,
3171 ScreenOrientationController::LockCompletionBehavior::None); 3167 ScreenOrientationController::LockCompletionBehavior::None);
3172 } 3168 }
3173 wm::ActivateWindow(window_a); 3169 wm::ActivateWindow(window_a);
3174 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 3170 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
3175 true);
3176 3171
3177 orientation_controller->OnAccelerometerUpdated(portrait_primary); 3172 orientation_controller->OnAccelerometerUpdated(portrait_primary);
3178 3173
3179 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary, 3174 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitPrimary,
3180 test_api.GetCurrentOrientation()); 3175 test_api.GetCurrentOrientation());
3181 3176
3182 orientation_controller->OnAccelerometerUpdated(portrait_secondary); 3177 orientation_controller->OnAccelerometerUpdated(portrait_secondary);
3183 3178
3184 aura::Window* window_ps = CreateTestWindowInShellWithId(1); 3179 aura::Window* window_ps = CreateTestWindowInShellWithId(1);
3185 { 3180 {
(...skipping 21 matching lines...) Expand all
3207 test_api.GetCurrentOrientation()); 3202 test_api.GetCurrentOrientation());
3208 3203
3209 // The orientation has alraedy been locked to secondary once, so 3204 // The orientation has alraedy been locked to secondary once, so
3210 // it should swtich back to the portrait secondary. 3205 // it should swtich back to the portrait secondary.
3211 wm::ActivateWindow(window_ps); 3206 wm::ActivateWindow(window_ps);
3212 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary, 3207 EXPECT_EQ(blink::kWebScreenOrientationLockPortraitSecondary,
3213 test_api.GetCurrentOrientation()); 3208 test_api.GetCurrentOrientation());
3214 } 3209 }
3215 3210
3216 } // namespace ash 3211 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698