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

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

Issue 2766543002: Move even more from WmShell to Shell (Closed)
Patch Set: Created 3 years, 9 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/chromeos/rotation/tray_rotation_lock.h" 5 #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
6 6
7 #include <memory> 7 #include <memory>
8 8
9 #include "ash/common/system/status_area_widget.h" 9 #include "ash/common/system/status_area_widget.h"
10 #include "ash/common/system/tray/system_tray.h" 10 #include "ash/common/system/tray/system_tray.h"
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
112 // Tests that when the tray view is initially created, that it is created 112 // Tests that when the tray view is initially created, that it is created
113 // not visible. 113 // not visible.
114 TEST_F(TrayRotationLockTest, CreateTrayView) { 114 TEST_F(TrayRotationLockTest, CreateTrayView) {
115 EXPECT_FALSE(tray_view()->visible()); 115 EXPECT_FALSE(tray_view()->visible());
116 } 116 }
117 117
118 // Tests that when the tray view is created, while MaximizeMode is active, that 118 // Tests that when the tray view is created, while MaximizeMode is active, that
119 // it is not visible. 119 // it is not visible.
120 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) { 120 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeMode) {
121 TearDownViews(); 121 TearDownViews();
122 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 122 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
123 true); 123 true);
124 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); 124 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
125 EXPECT_FALSE(tray_view()->visible()); 125 EXPECT_FALSE(tray_view()->visible());
126 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 126 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
127 false); 127 false);
128 } 128 }
129 129
130 // Tests that when the tray view is created, while MaximizeMode is active, and 130 // Tests that when the tray view is created, while MaximizeMode is active, and
131 // rotation is locked, that it is visible. 131 // rotation is locked, that it is visible.
132 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) { 132 TEST_F(TrayRotationLockTest, CreateTrayViewDuringMaximizeModeAndRotationLock) {
133 TearDownViews(); 133 TearDownViews();
134 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 134 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
135 true); 135 true);
136 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 136 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
137 true); 137 true);
138 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); 138 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
139 EXPECT_TRUE(tray_view()->visible()); 139 EXPECT_TRUE(tray_view()->visible());
140 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 140 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
141 false); 141 false);
142 EXPECT_FALSE(tray_view()->visible()); 142 EXPECT_FALSE(tray_view()->visible());
143 } 143 }
144 144
145 // Tests that the enabling of MaximizeMode affects a previously created tray 145 // Tests that the enabling of MaximizeMode affects a previously created tray
146 // view, changing the visibility. 146 // view, changing the visibility.
147 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) { 147 TEST_F(TrayRotationLockTest, TrayViewVisibilityChangesDuringMaximizeMode) {
148 ASSERT_FALSE(tray_view()->visible()); 148 ASSERT_FALSE(tray_view()->visible());
149 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 149 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
150 true); 150 true);
151 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 151 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
152 true); 152 true);
153 EXPECT_TRUE(tray_view()->visible()); 153 EXPECT_TRUE(tray_view()->visible());
154 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 154 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
155 false); 155 false);
156 EXPECT_FALSE(tray_view()->visible()); 156 EXPECT_FALSE(tray_view()->visible());
157 } 157 }
158 158
159 // Tests that the when the tray view is created for a secondary display, that 159 // Tests that the when the tray view is created for a secondary display, that
160 // it is not visible, and that MaximizeMode does not affect visibility. 160 // it is not visible, and that MaximizeMode does not affect visibility.
161 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) { 161 TEST_F(TrayRotationLockTest, CreateSecondaryTrayView) {
162 UpdateDisplay("400x400,200x200"); 162 UpdateDisplay("400x400,200x200");
163 163
164 SetUpForStatusAreaWidget( 164 SetUpForStatusAreaWidget(
165 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); 165 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget());
166 EXPECT_FALSE(tray_view()->visible()); 166 EXPECT_FALSE(tray_view()->visible());
167 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 167 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
168 true); 168 true);
169 EXPECT_FALSE(tray_view()->visible()); 169 EXPECT_FALSE(tray_view()->visible());
170 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 170 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
171 false); 171 false);
172 EXPECT_FALSE(tray_view()->visible()); 172 EXPECT_FALSE(tray_view()->visible());
173 } 173 }
174 174
175 // Tests that when the default view is initially created, that it is created 175 // Tests that when the default view is initially created, that it is created
176 // not visible. 176 // not visible.
177 TEST_F(TrayRotationLockTest, CreateDefaultView) { 177 TEST_F(TrayRotationLockTest, CreateDefaultView) {
178 EXPECT_FALSE(default_view()->visible()); 178 EXPECT_FALSE(default_view()->visible());
179 } 179 }
180 180
181 // Tests that when the default view is created, while MaximizeMode is active, 181 // Tests that when the default view is created, while MaximizeMode is active,
182 // that it is visible. 182 // that it is visible.
183 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) { 183 TEST_F(TrayRotationLockTest, CreateDefaultViewDuringMaximizeMode) {
184 TearDownViews(); 184 TearDownViews();
185 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 185 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
186 true); 186 true);
187 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget()); 187 SetUpForStatusAreaWidget(StatusAreaWidgetTestHelper::GetStatusAreaWidget());
188 EXPECT_TRUE(default_view()->visible()); 188 EXPECT_TRUE(default_view()->visible());
189 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 189 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
190 false); 190 false);
191 } 191 }
192 192
193 // Tests that the enabling of MaximizeMode affects a previously created default 193 // Tests that the enabling of MaximizeMode affects a previously created default
194 // view, changing the visibility. 194 // view, changing the visibility.
195 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) { 195 TEST_F(TrayRotationLockTest, DefaultViewVisibilityChangesDuringMaximizeMode) {
196 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 196 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
197 true); 197 true);
198 EXPECT_TRUE(default_view()->visible()); 198 EXPECT_TRUE(default_view()->visible());
199 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 199 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
200 false); 200 false);
201 EXPECT_FALSE(default_view()->visible()); 201 EXPECT_FALSE(default_view()->visible());
202 } 202 }
203 203
204 // Tests that no default view is created when the target is a secondary 204 // Tests that no default view is created when the target is a secondary
205 // display. 205 // display.
206 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) { 206 TEST_F(TrayRotationLockTest, CreateSecondaryDefaultView) {
207 UpdateDisplay("400x400,200x200"); 207 UpdateDisplay("400x400,200x200");
208 208
209 TearDownViews(); 209 TearDownViews();
210 SetUpForStatusAreaWidget( 210 SetUpForStatusAreaWidget(
211 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget()); 211 StatusAreaWidgetTestHelper::GetSecondaryStatusAreaWidget());
212 EXPECT_EQ(NULL, default_view()); 212 EXPECT_EQ(NULL, default_view());
213 } 213 }
214 214
215 // Tests that activating the default view causes the display to have its 215 // Tests that activating the default view causes the display to have its
216 // rotation locked, and that the tray view becomes visible. 216 // rotation locked, and that the tray view becomes visible.
217 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) { 217 TEST_F(TrayRotationLockTest, PerformActionOnDefaultView) {
218 MaximizeModeController* maximize_mode_controller = 218 MaximizeModeController* maximize_mode_controller =
219 WmShell::Get()->maximize_mode_controller(); 219 Shell::Get()->maximize_mode_controller();
220 ScreenOrientationController* screen_orientation_controller = 220 ScreenOrientationController* screen_orientation_controller =
221 Shell::GetInstance()->screen_orientation_controller(); 221 Shell::GetInstance()->screen_orientation_controller();
222 ASSERT_FALSE(screen_orientation_controller->rotation_locked()); 222 ASSERT_FALSE(screen_orientation_controller->rotation_locked());
223 maximize_mode_controller->EnableMaximizeModeWindowManager(true); 223 maximize_mode_controller->EnableMaximizeModeWindowManager(true);
224 ASSERT_FALSE(tray_view()->visible()); 224 ASSERT_FALSE(tray_view()->visible());
225 225
226 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(), 226 ui::GestureEvent tap(0, 0, 0, base::TimeTicks(),
227 ui::GestureEventDetails(ui::ET_GESTURE_TAP)); 227 ui::GestureEventDetails(ui::ET_GESTURE_TAP));
228 default_view()->OnGestureEvent(&tap); 228 default_view()->OnGestureEvent(&tap);
229 EXPECT_TRUE(screen_orientation_controller->rotation_locked()); 229 EXPECT_TRUE(screen_orientation_controller->rotation_locked());
(...skipping 10 matching lines...) Expand all
240 display::Display::SetInternalDisplayId(display::kInvalidDisplayId); 240 display::Display::SetInternalDisplayId(display::kInvalidDisplayId);
241 241
242 std::unique_ptr<TrayRotationLock> tray(new TrayRotationLock( 242 std::unique_ptr<TrayRotationLock> tray(new TrayRotationLock(
243 StatusAreaWidgetTestHelper::GetStatusAreaWidget()->system_tray())); 243 StatusAreaWidgetTestHelper::GetStatusAreaWidget()->system_tray()));
244 244
245 display::Display::SetInternalDisplayId(internal_display_id); 245 display::Display::SetInternalDisplayId(internal_display_id);
246 std::unique_ptr<views::View> tray_view(CreateTrayView(tray.get())); 246 std::unique_ptr<views::View> tray_view(CreateTrayView(tray.get()));
247 std::unique_ptr<views::View> default_view(tray->CreateDefaultView( 247 std::unique_ptr<views::View> default_view(tray->CreateDefaultView(
248 StatusAreaWidgetTestHelper::GetUserLoginStatus())); 248 StatusAreaWidgetTestHelper::GetUserLoginStatus()));
249 EXPECT_TRUE(default_view); 249 EXPECT_TRUE(default_view);
250 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 250 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
251 true); 251 true);
252 EXPECT_TRUE(default_view->visible()); 252 EXPECT_TRUE(default_view->visible());
253 } 253 }
254 254
255 // Tests that when the tray view is deleted, while TrayRotationLock has not been 255 // Tests that when the tray view is deleted, while TrayRotationLock has not been
256 // deleted, that updates to the rotation lock state do not crash. 256 // deleted, that updates to the rotation lock state do not crash.
257 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) { 257 TEST_F(TrayRotationLockTest, LockUpdatedDuringDesctruction) {
258 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 258 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
259 true); 259 true);
260 DestroyTrayView(); 260 DestroyTrayView();
261 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 261 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
262 true); 262 true);
263 WmShell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager( 263 Shell::Get()->maximize_mode_controller()->EnableMaximizeModeWindowManager(
264 false); 264 false);
265 } 265 }
266 266
267 } // namespace ash 267 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/rotation/tray_rotation_lock.cc ('k') | ash/system/overview/overview_button_tray_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698