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

Side by Side Diff: ash/system/rotation/tray_rotation_lock_unittest.cc

Issue 2906803002: Rename MaximizeMode to TabletMode (Closed)
Patch Set: updated filter Created 3 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/system/rotation/tray_rotation_lock.h" 5 #include "ash/system/rotation/tray_rotation_lock.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/display/screen_orientation_controller_chromeos.h" 9 #include "ash/display/screen_orientation_controller_chromeos.h"
10 #include "ash/root_window_controller.h" 10 #include "ash/root_window_controller.h"
11 #include "ash/shell.h" 11 #include "ash/shell.h"
12 #include "ash/system/status_area_widget.h" 12 #include "ash/system/status_area_widget.h"
13 #include "ash/system/tray/system_tray.h" 13 #include "ash/system/tray/system_tray.h"
14 #include "ash/system/tray/system_tray_delegate.h" 14 #include "ash/system/tray/system_tray_delegate.h"
15 #include "ash/test/ash_test_base.h" 15 #include "ash/test/ash_test_base.h"
16 #include "ash/test/status_area_widget_test_helper.h" 16 #include "ash/test/status_area_widget_test_helper.h"
17 #include "ash/wm/maximize_mode/maximize_mode_controller.h" 17 #include "ash/wm/tablet_mode/tablet_mode_controller.h"
18 #include "base/command_line.h" 18 #include "base/command_line.h"
19 #include "base/time/time.h" 19 #include "base/time/time.h"
20 #include "ui/display/display_switches.h" 20 #include "ui/display/display_switches.h"
21 #include "ui/display/manager/display_manager.h" 21 #include "ui/display/manager/display_manager.h"
22 #include "ui/display/types/display_constants.h" 22 #include "ui/display/types/display_constants.h"
23 #include "ui/events/event.h" 23 #include "ui/events/event.h"
24 #include "ui/events/event_constants.h" 24 #include "ui/events/event_constants.h"
25 #include "ui/views/view.h" 25 #include "ui/views/view.h"
26 26
27 namespace ash { 27 namespace ash {
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
107 TearDownViews(); 107 TearDownViews();
108 test::AshTestBase::TearDown(); 108 test::AshTestBase::TearDown();
109 } 109 }
110 110
111 // Tests that when the tray view is initially created, that it is created 111 // Tests that when the tray view is initially created, that it is created
112 // not visible. 112 // not visible.
113 TEST_F(TrayRotationLockTest, CreateTrayView) { 113 TEST_F(TrayRotationLockTest, CreateTrayView) {
114 EXPECT_FALSE(tray_view()->visible()); 114 EXPECT_FALSE(tray_view()->visible());
115 } 115 }
116 116
117 // Tests that when the tray view is created, while MaximizeMode is active, that 117 // Tests that when the tray view is created, while TabletMode is active, that
118 // it must be visible, and becomes invisible exiting MaximizeMode. 118 // it must be visible, and becomes invisible exiting TabletMode.
119 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { 119 TEST_F(TrayRotationLockTest, CreateTrayViewDuringTabletMode) {
120 TearDownViews(); 120 TearDownViews();
121 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 121 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
122 true);
123 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); 122 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
124 EXPECT_TRUE(tray_view()->visible()); 123 EXPECT_TRUE(tray_view()->visible());
125 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 124 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
126 false);
127 EXPECT_FALSE(tray_view()->visible()); 125 EXPECT_FALSE(tray_view()->visible());
128 } 126 }
129 127
130 // Tests that the enabling of MaximizeMode affects a previously created tray 128 // Tests that the enabling of TabletMode affects a previously created tray
131 // view, changing the visibility. 129 // view, changing the visibility.
132 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { 130 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringTabletMode) {
133 ASSERT_FALSE(tray_view()->visible()); 131 ASSERT_FALSE(tray_view()->visible());
134 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 132 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
135 true);
136 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); 133 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock();
137 EXPECT_TRUE(tray_view()->visible()); 134 EXPECT_TRUE(tray_view()->visible());
138 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 135 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
139 false);
140 EXPECT_FALSE(tray_view()->visible()); 136 EXPECT_FALSE(tray_view()->visible());
141 } 137 }
142 138
143 // Tests that when the tray view is created for a secondary display, that it is 139 // Tests that when the tray view is created for a secondary display, that it is
144 // not visible, and that MaximizeMode does not affect visibility. 140 // not visible, and that TabletMode does not affect visibility.
145 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { 141 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) {
146 UpdateDisplay("400x400,200x200"); 142 UpdateDisplay("400x400,200x200");
147 143
148 SetUpForStatusAreaWidget( 144 SetUpForStatusAreaWidget(
149 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); 145 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget());
150 EXPECT_FALSE(tray_view()->visible()); 146 EXPECT_FALSE(tray_view()->visible());
151 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 147 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
152 true);
153 EXPECT_FALSE(tray_view()->visible()); 148 EXPECT_FALSE(tray_view()->visible());
154 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 149 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
155 false);
156 EXPECT_FALSE(tray_view()->visible()); 150 EXPECT_FALSE(tray_view()->visible());
157 } 151 }
158 152
159 // Tests that when the default view is initially created, that it is created 153 // Tests that when the default view is initially created, that it is created
160 // not visible. 154 // not visible.
161 TEST_F(TrayRotationLockTest, CreateDefaultView) { 155 TEST_F(TrayRotationLockTest, CreateDefaultView) {
162 EXPECT_FALSE(default_view()->visible()); 156 EXPECT_FALSE(default_view()->visible());
163 } 157 }
164 158
165 // Tests that when the default view is created, while MaximizeMode is active, 159 // Tests that when the default view is created, while TabletMode is active,
166 // that it is visible. 160 // that it is visible.
167 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { 161 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringTabletMode) {
168 TearDownViews(); 162 TearDownViews();
169 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 163 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
170 true);
171 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); 164 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
172 EXPECT_TRUE(default_view()->visible()); 165 EXPECT_TRUE(default_view()->visible());
173 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 166 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
174 false);
175 EXPECT_FALSE(default_view()->visible()); 167 EXPECT_FALSE(default_view()->visible());
176 } 168 }
177 169
178 // Tests that the enabling of MaximizeMode affects a previously created default 170 // Tests that the enabling of TabletMode affects a previously created default
179 // view, changing the visibility. 171 // view, changing the visibility.
180 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { 172 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringTabletMode) {
181 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 173 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
182 true);
183 EXPECT_TRUE(default_view()->visible()); 174 EXPECT_TRUE(default_view()->visible());
184 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 175 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
185 false);
186 EXPECT_FALSE(default_view()->visible()); 176 EXPECT_FALSE(default_view()->visible());
187 } 177 }
188 178
189 // Tests that no default view is created when the target is a secondary 179 // Tests that no default view is created when the target is a secondary
190 // display. 180 // display.
191 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { 181 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) {
192 UpdateDisplay("400x400,200x200"); 182 UpdateDisplay("400x400,200x200");
193 183
194 TearDownViews(); 184 TearDownViews();
195 SetUpForStatusAreaWidget( 185 SetUpForStatusAreaWidget(
196 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); 186 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget());
197 EXPECT_EQ(NULL, default_view()); 187 EXPECT_EQ(NULL, default_view());
198 } 188 }
199 189
200 // Tests that activating the default view causes the display to have its 190 // Tests that activating the default view causes the display to have its
201 // rotation locked. 191 // rotation locked.
202 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { 192 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) {
203 MaximizeModeController* maximize_mode_controller = 193 TabletModeController* tablet_mode_controller =
204 Shell::Get()->maximize_mode_controller(); 194 Shell::Get()->tablet_mode_controller();
205 ScreenOrientationController* screen_orientation_controller = 195 ScreenOrientationController* screen_orientation_controller =
206 Shell::Get()->screen_orientation_controller(); 196 Shell::Get()->screen_orientation_controller();
207 ASSERT_FALSE(screen_orientation_controller->rotation_locked()); 197 ASSERT_FALSE(screen_orientation_controller->rotation_locked());
208 maximize_mode_controller->EnableMaximizeModeWindowManager(true); 198 tablet_mode_controller->EnableTabletModeWindowManager(true);
209 ASSERT_TRUE(tray_view()->visible()); 199 ASSERT_TRUE(tray_view()->visible());
210 200
211 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), 201 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(),
212 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); 202 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
213 default_view()->OnGestureEvent(&tap); 203 default_view()->OnGestureEvent(&tap);
214 EXPECT_TRUE(screen_orientation_controller->rotation_locked()); 204 EXPECT_TRUE(screen_orientation_controller->rotation_locked());
215 EXPECT_TRUE(tray_view()->visible()); 205 EXPECT_TRUE(tray_view()->visible());
216 206
217 maximize_mode_controller->EnableMaximizeModeWindowManager(false); 207 tablet_mode_controller->EnableTabletModeWindowManager(false);
218 } 208 }
219 209
220 // Tests that when the tray is created without the internal display being known, 210 // Tests that when the tray is created without the internal display being known,
221 // that it will still display correctly once the internal display is known. 211 // that it will still display correctly once the internal display is known.
222 TEST_F(TrayRotationLockTest, InternalDisplayNotAvailableAtCreation) { 212 TEST_F(TrayRotationLockTest, InternalDisplayNotAvailableAtCreation) {
223 int64_t internal_display_id = display::Display::InternalDisplayId(); 213 int64_t internal_display_id = display::Display::InternalDisplayId();
224 TearDownViews(); 214 TearDownViews();
225 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); 215 display::Display::SetInternalDisplayId(display::kInvalidDisplayId);
226 216
227 std::unique_ptr<TrayRotationLock> tray(new TrayRotationLock( 217 std::unique_ptr<TrayRotationLock> tray(new TrayRotationLock(
228 StatusAreaWidgetTestHelper::GetStatusAreaWidget()->system_tray())); 218 StatusAreaWidgetTestHelper::GetStatusAreaWidget()->system_tray()));
229 219
230 display::Display::SetInternalDisplayId(internal_display_id); 220 display::Display::SetInternalDisplayId(internal_display_id);
231 std::unique_ptr<views::View> tray_view(CreateTrayView(tray.get())); 221 std::unique_ptr<views::View> tray_view(CreateTrayView(tray.get()));
232 std::unique_ptr<views::View> default_view(tray->CreateDefaultView( 222 std::unique_ptr<views::View> default_view(tray->CreateDefaultView(
233 StatusAreaWidgetTestHelper::GetUserLoginStatus())); 223 StatusAreaWidgetTestHelper::GetUserLoginStatus()));
234 EXPECT_TRUE(default_view); 224 EXPECT_TRUE(default_view);
235 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 225 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
236 true);
237 EXPECT_TRUE(default_view->visible()); 226 EXPECT_TRUE(default_view->visible());
238 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 227 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
239 false);
240 } 228 }
241 229
242 // Tests that when the tray view is deleted, while TrayRotationLock has not been 230 // Tests that when the tray view is deleted, while TrayRotationLock has not been
243 // deleted, that updates to the rotation lock state do not crash. 231 // deleted, that updates to the rotation lock state do not crash.
244 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) { 232 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) {
245 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 233 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(true);
246 true);
247 DestroyTrayView(); 234 DestroyTrayView();
248 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock(); 235 Shell::Get()->screen_orientation_controller()->ToggleUserRotationLock();
249 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 236 Shell::Get()->tablet_mode_controller()->EnableTabletModeWindowManager(false);
250 false);
251 } 237 }
252 238
253 } // namespace ash 239 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698