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

Side by Side Diff: ash/content/display/screen_orientation_controller_chromeos_unittest.cc

Issue 1108343002: Revert of Merge Prevent DisplayPreferences from saving incorrect rotations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2357
Patch Set: Created 5 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 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/ash_switches.h" 5 #include "ash/ash_switches.h"
6 #include "ash/content/display/screen_orientation_controller_chromeos.h" 6 #include "ash/content/display/screen_orientation_controller_chromeos.h"
7 #include "ash/display/display_info.h" 7 #include "ash/display/display_info.h"
8 #include "ash/display/display_manager.h" 8 #include "ash/display/display_manager.h"
9 #include "ash/shell.h" 9 #include "ash/shell.h"
10 #include "ash/test/ash_test_base.h" 10 #include "ash/test/ash_test_base.h"
(...skipping 23 matching lines...) Expand all
34 34
35 const float kDegreesToRadians = 3.1415926f / 180.0f; 35 const float kDegreesToRadians = 3.1415926f / 180.0f;
36 const float kMeanGravity = 9.8066f; 36 const float kMeanGravity = 9.8066f;
37 37
38 void EnableMaximizeMode(bool enable) { 38 void EnableMaximizeMode(bool enable) {
39 Shell::GetInstance() 39 Shell::GetInstance()
40 ->maximize_mode_controller() 40 ->maximize_mode_controller()
41 ->EnableMaximizeModeWindowManager(enable); 41 ->EnableMaximizeModeWindowManager(enable);
42 } 42 }
43 43
44 gfx::Display::Rotation GetInternalDisplayRotation() {
45 return Shell::GetInstance()
46 ->display_manager()
47 ->GetDisplayInfo(gfx::Display::InternalDisplayId())
48 .rotation();
49 }
50
51 gfx::Display::Rotation Rotation() {
52 return Shell::GetInstance()
53 ->display_manager()
54 ->GetDisplayInfo(gfx::Display::InternalDisplayId())
55 .rotation();
56 }
57
44 bool RotationLocked() { 58 bool RotationLocked() {
45 return Shell::GetInstance() 59 return Shell::GetInstance()
46 ->screen_orientation_controller() 60 ->screen_orientation_controller()
47 ->rotation_locked(); 61 ->rotation_locked();
48 } 62 }
49 63
50 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) { 64 void SetInternalDisplayRotation(gfx::Display::Rotation rotation) {
51 Shell::GetInstance()->display_manager()->SetDisplayRotation( 65 Shell::GetInstance()->display_manager()->SetDisplayRotation(
52 gfx::Display::InternalDisplayId(), rotation, 66 gfx::Display::InternalDisplayId(), rotation);
53 gfx::Display::ROTATION_SOURCE_USER);
54 } 67 }
55 68
56 void SetRotationLocked(bool rotation_locked) { 69 void SetRotationLocked(bool rotation_locked) {
57 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked( 70 Shell::GetInstance()->screen_orientation_controller()->SetRotationLocked(
58 rotation_locked); 71 rotation_locked);
59 } 72 }
60 73
61 void TriggerLidUpdate(const gfx::Vector3dF& lid) { 74 void TriggerLidUpdate(const gfx::Vector3dF& lid) {
62 scoped_refptr<chromeos::AccelerometerUpdate> update( 75 scoped_refptr<chromeos::AccelerometerUpdate> update(
63 new chromeos::AccelerometerUpdate()); 76 new chromeos::AccelerometerUpdate());
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
146 test::AshTestBase::SetUp(); 159 test::AshTestBase::SetUp();
147 screen_orientation_controller_ = 160 screen_orientation_controller_ =
148 Shell::GetInstance()->screen_orientation_controller(); 161 Shell::GetInstance()->screen_orientation_controller();
149 } 162 }
150 163
151 // Tests that a content::WebContents can lock rotation. 164 // Tests that a content::WebContents can lock rotation.
152 TEST_F(ScreenOrientationControllerTest, LockOrientation) { 165 TEST_F(ScreenOrientationControllerTest, LockOrientation) {
153 scoped_ptr<content::WebContents> content(CreateWebContents()); 166 scoped_ptr<content::WebContents> content(CreateWebContents());
154 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 167 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
155 ASSERT_NE(nullptr, content->GetNativeView()); 168 ASSERT_NE(nullptr, content->GetNativeView());
156 ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 169 ASSERT_EQ(gfx::Display::ROTATE_0, Rotation());
157 ASSERT_FALSE(RotationLocked()); 170 ASSERT_FALSE(RotationLocked());
158 171
159 AttachAndActivateWebContents(content.get(), focus_window.get()); 172 AttachAndActivateWebContents(content.get(), focus_window.get());
160 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 173 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
161 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 174 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
162 EXPECT_TRUE(RotationLocked()); 175 EXPECT_TRUE(RotationLocked());
163 } 176 }
164 177
165 // Tests that a content::WebContents can unlock rotation. 178 // Tests that a content::WebContents can unlock rotation.
166 TEST_F(ScreenOrientationControllerTest, Unlock) { 179 TEST_F(ScreenOrientationControllerTest, Unlock) {
167 scoped_ptr<content::WebContents> content(CreateWebContents()); 180 scoped_ptr<content::WebContents> content(CreateWebContents());
168 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 181 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
169 ASSERT_NE(nullptr, content->GetNativeView()); 182 ASSERT_NE(nullptr, content->GetNativeView());
170 ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 183 ASSERT_EQ(gfx::Display::ROTATE_0, Rotation());
171 ASSERT_FALSE(RotationLocked()); 184 ASSERT_FALSE(RotationLocked());
172 185
173 AttachAndActivateWebContents(content.get(), focus_window.get()); 186 AttachAndActivateWebContents(content.get(), focus_window.get());
174 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 187 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
175 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 188 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
176 EXPECT_TRUE(RotationLocked()); 189 EXPECT_TRUE(RotationLocked());
177 190
178 delegate()->Unlock(content.get()); 191 delegate()->Unlock(content.get());
179 EXPECT_FALSE(RotationLocked()); 192 EXPECT_FALSE(RotationLocked());
180 } 193 }
181 194
182 // Tests that a content::WebContents is able to change the orientation of the 195 // Tests that a content::WebContents is able to change the orientation of the
183 // display after having locked rotation. 196 // display after having locked rotation.
184 TEST_F(ScreenOrientationControllerTest, OrientationChanges) { 197 TEST_F(ScreenOrientationControllerTest, OrientationChanges) {
185 scoped_ptr<content::WebContents> content(CreateWebContents()); 198 scoped_ptr<content::WebContents> content(CreateWebContents());
186 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 199 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
187 ASSERT_NE(nullptr, content->GetNativeView()); 200 ASSERT_NE(nullptr, content->GetNativeView());
188 ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 201 ASSERT_EQ(gfx::Display::ROTATE_0, Rotation());
189 ASSERT_FALSE(RotationLocked()); 202 ASSERT_FALSE(RotationLocked());
190 203
191 AttachAndActivateWebContents(content.get(), focus_window.get()); 204 AttachAndActivateWebContents(content.get(), focus_window.get());
192 delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); 205 delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait);
193 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 206 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation());
194 EXPECT_TRUE(RotationLocked()); 207 EXPECT_TRUE(RotationLocked());
195 208
196 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 209 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
197 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 210 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
198 } 211 }
199 212
200 // Tests that orientation can only be set by the first content::WebContents that 213 // Tests that orientation can only be set by the first content::WebContents that
201 // has set a rotation lock. 214 // has set a rotation lock.
202 TEST_F(ScreenOrientationControllerTest, SecondContentCannotChangeOrientation) { 215 TEST_F(ScreenOrientationControllerTest, SecondContentCannotChangeOrientation) {
203 scoped_ptr<content::WebContents> content1(CreateWebContents()); 216 scoped_ptr<content::WebContents> content1(CreateWebContents());
204 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents()); 217 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents());
205 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0)); 218 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0));
206 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1)); 219 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1));
207 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView()); 220 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView());
208 221
209 AttachAndActivateWebContents(content1.get(), focus_window1.get()); 222 AttachAndActivateWebContents(content1.get(), focus_window1.get());
210 AttachWebContents(content2.get(), focus_window2.get()); 223 AttachWebContents(content2.get(), focus_window2.get());
211 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); 224 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape);
212 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); 225 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait);
213 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 226 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
214 } 227 }
215 228
216 // Tests that only the content::WebContents that set a rotation lock can perform 229 // Tests that only the content::WebContents that set a rotation lock can perform
217 // an unlock. 230 // an unlock.
218 TEST_F(ScreenOrientationControllerTest, SecondContentCannotUnlock) { 231 TEST_F(ScreenOrientationControllerTest, SecondContentCannotUnlock) {
219 scoped_ptr<content::WebContents> content1(CreateWebContents()); 232 scoped_ptr<content::WebContents> content1(CreateWebContents());
220 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents()); 233 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents());
221 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0)); 234 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0));
222 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1)); 235 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1));
223 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView()); 236 ASSERT_NE(content1->GetNativeView(), content2->GetNativeView());
(...skipping 30 matching lines...) Expand all
254 TEST_F(ScreenOrientationControllerTest, ActiveWindowChangesUpdateOrientation) { 267 TEST_F(ScreenOrientationControllerTest, ActiveWindowChangesUpdateOrientation) {
255 scoped_ptr<content::WebContents> content1(CreateWebContents()); 268 scoped_ptr<content::WebContents> content1(CreateWebContents());
256 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents()); 269 scoped_ptr<content::WebContents> content2(CreateSecondaryWebContents());
257 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0)); 270 scoped_ptr<aura::Window> focus_window1(CreateTestWindowInShellWithId(0));
258 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1)); 271 scoped_ptr<aura::Window> focus_window2(CreateTestWindowInShellWithId(1));
259 AttachAndActivateWebContents(content1.get(), focus_window1.get()); 272 AttachAndActivateWebContents(content1.get(), focus_window1.get());
260 AttachWebContents(content2.get(), focus_window2.get()); 273 AttachWebContents(content2.get(), focus_window2.get());
261 274
262 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); 275 delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape);
263 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); 276 delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait);
264 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 277 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
265 278
266 aura::client::ActivationClient* activation_client = 279 aura::client::ActivationClient* activation_client =
267 Shell::GetInstance()->activation_client(); 280 Shell::GetInstance()->activation_client();
268 activation_client->ActivateWindow(focus_window2.get()); 281 activation_client->ActivateWindow(focus_window2.get());
269 EXPECT_TRUE(RotationLocked()); 282 EXPECT_TRUE(RotationLocked());
270 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 283 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
271 284
272 activation_client->ActivateWindow(focus_window1.get()); 285 activation_client->ActivateWindow(focus_window1.get());
273 EXPECT_TRUE(RotationLocked()); 286 EXPECT_TRUE(RotationLocked());
274 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 287 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
275 } 288 }
276 289
277 // Tests that a rotation lock is removed when the setting window is hidden, and 290 // Tests that a rotation lock is removed when the setting window is hidden, and
278 // that it is reapplied when the window becomes visible. 291 // that it is reapplied when the window becomes visible.
279 TEST_F(ScreenOrientationControllerTest, VisibilityChangesLock) { 292 TEST_F(ScreenOrientationControllerTest, VisibilityChangesLock) {
280 scoped_ptr<content::WebContents> content(CreateWebContents()); 293 scoped_ptr<content::WebContents> content(CreateWebContents());
281 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 294 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
282 AttachAndActivateWebContents(content.get(), focus_window.get()); 295 AttachAndActivateWebContents(content.get(), focus_window.get());
283 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 296 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
284 EXPECT_TRUE(RotationLocked()); 297 EXPECT_TRUE(RotationLocked());
(...skipping 29 matching lines...) Expand all
314 activation_client->ActivateWindow(focus_window1.get()); 327 activation_client->ActivateWindow(focus_window1.get());
315 EXPECT_FALSE(RotationLocked()); 328 EXPECT_FALSE(RotationLocked());
316 } 329 }
317 330
318 // Tests that accelerometer readings in each of the screen angles will trigger a 331 // Tests that accelerometer readings in each of the screen angles will trigger a
319 // rotation of the internal display. 332 // rotation of the internal display.
320 TEST_F(ScreenOrientationControllerTest, DisplayRotation) { 333 TEST_F(ScreenOrientationControllerTest, DisplayRotation) {
321 EnableMaximizeMode(true); 334 EnableMaximizeMode(true);
322 // Now test rotating in all directions. 335 // Now test rotating in all directions.
323 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); 336 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
324 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 337 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
325 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 338 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
326 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 339 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
327 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); 340 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
328 EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 341 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
329 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); 342 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f));
330 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 343 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
331 } 344 }
332 345
333 // Tests that low angles are ignored by the accelerometer (i.e. when the device 346 // Tests that low angles are ignored by the accelerometer (i.e. when the device
334 // is almost laying flat). 347 // is almost laying flat).
335 TEST_F(ScreenOrientationControllerTest, RotationIgnoresLowAngles) { 348 TEST_F(ScreenOrientationControllerTest, RotationIgnoresLowAngles) {
336 EnableMaximizeMode(true); 349 EnableMaximizeMode(true);
337 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, -kMeanGravity)); 350 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, -kMeanGravity));
338 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 351 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
339 TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, -kMeanGravity)); 352 TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, -kMeanGravity));
340 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 353 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
341 TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, -kMeanGravity)); 354 TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, -kMeanGravity));
342 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 355 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
343 TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, -kMeanGravity)); 356 TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, -kMeanGravity));
344 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 357 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
345 TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, -kMeanGravity)); 358 TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, -kMeanGravity));
346 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 359 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
347 } 360 }
348 361
349 // Tests that the display will stick to the current orientation beyond the 362 // Tests that the display will stick to the current orientation beyond the
350 // halfway point, preventing frequent updates back and forth. 363 // halfway point, preventing frequent updates back and forth.
351 TEST_F(ScreenOrientationControllerTest, RotationSticky) { 364 TEST_F(ScreenOrientationControllerTest, RotationSticky) {
352 EnableMaximizeMode(true); 365 EnableMaximizeMode(true);
353 gfx::Vector3dF gravity(0.0f, -kMeanGravity, 0.0f); 366 gfx::Vector3dF gravity(0.0f, -kMeanGravity, 0.0f);
354 TriggerLidUpdate(gravity); 367 TriggerLidUpdate(gravity);
355 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 368 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
356 369
357 // Turn past half-way point to next direction and rotation should remain 370 // Turn past half-way point to next direction and rotation should remain
358 // the same. 371 // the same.
359 float degrees = 50.0; 372 float degrees = 50.0;
360 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); 373 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity);
361 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); 374 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity);
362 TriggerLidUpdate(gravity); 375 TriggerLidUpdate(gravity);
363 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 376 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
364 377
365 // Turn more and the screen should rotate. 378 // Turn more and the screen should rotate.
366 degrees = 70.0; 379 degrees = 70.0;
367 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); 380 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity);
368 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); 381 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity);
369 TriggerLidUpdate(gravity); 382 TriggerLidUpdate(gravity);
370 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 383 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
371 384
372 // Turn back just beyond the half-way point and the new rotation should 385 // Turn back just beyond the half-way point and the new rotation should
373 // still be in effect. 386 // still be in effect.
374 degrees = 40.0; 387 degrees = 40.0;
375 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); 388 gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity);
376 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); 389 gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity);
377 TriggerLidUpdate(gravity); 390 TriggerLidUpdate(gravity);
378 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 391 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
379 } 392 }
380 393
381 // Tests that the display will stick to its current orientation when the 394 // Tests that the display will stick to its current orientation when the
382 // rotation lock has been set. 395 // rotation lock has been set.
383 TEST_F(ScreenOrientationControllerTest, RotationLockPreventsRotation) { 396 TEST_F(ScreenOrientationControllerTest, RotationLockPreventsRotation) {
384 EnableMaximizeMode(true); 397 EnableMaximizeMode(true);
385 SetRotationLocked(true); 398 SetRotationLocked(true);
386 399
387 // Turn past the threshold for rotation. 400 // Turn past the threshold for rotation.
388 float degrees = 90.0; 401 float degrees = 90.0;
389 gfx::Vector3dF gravity(-sin(degrees * kDegreesToRadians) * kMeanGravity, 402 gfx::Vector3dF gravity(-sin(degrees * kDegreesToRadians) * kMeanGravity,
390 -cos(degrees * kDegreesToRadians) * kMeanGravity, 403 -cos(degrees * kDegreesToRadians) * kMeanGravity,
391 0.0f); 404 0.0f);
392 TriggerLidUpdate(gravity); 405 TriggerLidUpdate(gravity);
393 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 406 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
394 407
395 SetRotationLocked(false); 408 SetRotationLocked(false);
396 TriggerLidUpdate(gravity); 409 TriggerLidUpdate(gravity);
397 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 410 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
398 } 411 }
399 412
400 // The TrayDisplay class that is responsible for adding/updating MessageCenter 413 // The TrayDisplay class that is responsible for adding/updating MessageCenter
401 // notifications is only added to the SystemTray on ChromeOS. 414 // notifications is only added to the SystemTray on ChromeOS.
402 // Tests that the screen rotation notifications are suppressed when 415 // Tests that the screen rotation notifications are suppressed when
403 // triggered by the accelerometer. 416 // triggered by the accelerometer.
404 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) { 417 TEST_F(ScreenOrientationControllerTest, BlockRotationNotifications) {
405 EnableMaximizeMode(true); 418 EnableMaximizeMode(true);
406 test::TestSystemTrayDelegate* tray_delegate = 419 test::TestSystemTrayDelegate* tray_delegate =
407 static_cast<test::TestSystemTrayDelegate*>( 420 static_cast<test::TestSystemTrayDelegate*>(
408 Shell::GetInstance()->system_tray_delegate()); 421 Shell::GetInstance()->system_tray_delegate());
409 tray_delegate->set_should_show_display_notification(true); 422 tray_delegate->set_should_show_display_notification(true);
410 423
411 message_center::MessageCenter* message_center = 424 message_center::MessageCenter* message_center =
412 message_center::MessageCenter::Get(); 425 message_center::MessageCenter::Get();
413 426
414 EXPECT_EQ(0u, message_center->NotificationCount()); 427 EXPECT_EQ(0u, message_center->NotificationCount());
415 EXPECT_FALSE(message_center->HasPopupNotifications()); 428 EXPECT_FALSE(message_center->HasPopupNotifications());
416 429
417 // Make sure notifications are still displayed when 430 // Make sure notifications are still displayed when
418 // adjusting the screen rotation directly when in maximize mode 431 // adjusting the screen rotation directly when in maximize mode
419 ASSERT_NE(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 432 ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
420 SetInternalDisplayRotation(gfx::Display::ROTATE_270); 433 SetInternalDisplayRotation(gfx::Display::ROTATE_270);
421 SetRotationLocked(false); 434 SetRotationLocked(false);
422 EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 435 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
423 EXPECT_EQ(1u, message_center->NotificationCount()); 436 EXPECT_EQ(1u, message_center->NotificationCount());
424 EXPECT_TRUE(message_center->HasPopupNotifications()); 437 EXPECT_TRUE(message_center->HasPopupNotifications());
425 438
426 // Clear all notifications 439 // Clear all notifications
427 message_center->RemoveAllNotifications(false); 440 message_center->RemoveAllNotifications(false);
428 EXPECT_EQ(0u, message_center->NotificationCount()); 441 EXPECT_EQ(0u, message_center->NotificationCount());
429 EXPECT_FALSE(message_center->HasPopupNotifications()); 442 EXPECT_FALSE(message_center->HasPopupNotifications());
430 443
431 // Make sure notifications are blocked when adjusting the screen rotation 444 // Make sure notifications are blocked when adjusting the screen rotation
432 // via the accelerometer while in maximize mode 445 // via the accelerometer while in maximize mode
433 // Rotate the screen 90 degrees 446 // Rotate the screen 90 degrees
434 ASSERT_NE(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 447 ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
435 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); 448 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
436 ASSERT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 449 ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
437 EXPECT_EQ(0u, message_center->NotificationCount()); 450 EXPECT_EQ(0u, message_center->NotificationCount());
438 EXPECT_FALSE(message_center->HasPopupNotifications()); 451 EXPECT_FALSE(message_center->HasPopupNotifications());
439 452
440 // Make sure notifications are still displayed when 453 // Make sure notifications are still displayed when
441 // adjusting the screen rotation directly when not in maximize mode 454 // adjusting the screen rotation directly when not in maximize mode
442 EnableMaximizeMode(false); 455 EnableMaximizeMode(false);
443 // Reset the screen rotation. 456 // Reset the screen rotation.
444 SetInternalDisplayRotation(gfx::Display::ROTATE_0); 457 SetInternalDisplayRotation(gfx::Display::ROTATE_0);
445 // Clear all notifications 458 // Clear all notifications
446 message_center->RemoveAllNotifications(false); 459 message_center->RemoveAllNotifications(false);
447 ASSERT_NE(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 460 ASSERT_NE(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
448 ASSERT_EQ(0u, message_center->NotificationCount()); 461 ASSERT_EQ(0u, message_center->NotificationCount());
449 ASSERT_FALSE(message_center->HasPopupNotifications()); 462 ASSERT_FALSE(message_center->HasPopupNotifications());
450 SetInternalDisplayRotation(gfx::Display::ROTATE_180); 463 SetInternalDisplayRotation(gfx::Display::ROTATE_180);
451 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 464 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
452 EXPECT_EQ(1u, message_center->NotificationCount()); 465 EXPECT_EQ(1u, message_center->NotificationCount());
453 EXPECT_TRUE(message_center->HasPopupNotifications()); 466 EXPECT_TRUE(message_center->HasPopupNotifications());
454 } 467 }
455 468
456 // Tests that if a user has set a display rotation that it is restored upon 469 // Tests that if a user has set a display rotation that it is restored upon
457 // exiting maximize mode. 470 // exiting maximize mode.
458 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) { 471 TEST_F(ScreenOrientationControllerTest, ResetUserRotationUponExit) {
459 SetInternalDisplayRotation(gfx::Display::ROTATE_90); 472 SetInternalDisplayRotation(gfx::Display::ROTATE_90);
460 EnableMaximizeMode(true); 473 EnableMaximizeMode(true);
461 474
462 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 475 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
463 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 476 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
464 477
465 EnableMaximizeMode(false); 478 EnableMaximizeMode(false);
466 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 479 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
467 } 480 }
468 481
469 // Tests that if a user sets a display rotation that accelerometer rotation 482 // Tests that if a user sets a display rotation that accelerometer rotation
470 // becomes locked. 483 // becomes locked.
471 TEST_F(ScreenOrientationControllerTest, 484 TEST_F(ScreenOrientationControllerTest,
472 NonAccelerometerRotationChangesLockRotation) { 485 NonAccelerometerRotationChangesLockRotation) {
473 EnableMaximizeMode(true); 486 EnableMaximizeMode(true);
474 ASSERT_FALSE(RotationLocked()); 487 ASSERT_FALSE(RotationLocked());
475 SetInternalDisplayRotation(gfx::Display::ROTATE_270); 488 SetInternalDisplayRotation(gfx::Display::ROTATE_270);
476 EXPECT_TRUE(RotationLocked()); 489 EXPECT_TRUE(RotationLocked());
477 } 490 }
478 491
479 // Tests that if a user changes the display rotation, while rotation is locked, 492 // Tests that if a user changes the display rotation, while rotation is locked,
480 // that the updates are recorded. Upon exiting maximize mode the latest user 493 // that the updates are recorded. Upon exiting maximize mode the latest user
481 // rotation should be applied. 494 // rotation should be applied.
482 TEST_F(ScreenOrientationControllerTest, UpdateUserRotationWhileRotationLocked) { 495 TEST_F(ScreenOrientationControllerTest, UpdateUserRotationWhileRotationLocked) {
483 EnableMaximizeMode(true); 496 EnableMaximizeMode(true);
484 SetInternalDisplayRotation(gfx::Display::ROTATE_270); 497 SetInternalDisplayRotation(gfx::Display::ROTATE_270);
485 // User sets rotation to the same rotation that the display was at when 498 // User sets rotation to the same rotation that the display was at when
486 // maximize mode was activated. 499 // maximize mode was activated.
487 SetInternalDisplayRotation(gfx::Display::ROTATE_0); 500 SetInternalDisplayRotation(gfx::Display::ROTATE_0);
488 EnableMaximizeMode(false); 501 EnableMaximizeMode(false);
489 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 502 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
490 } 503 }
491 504
492 // Tests that when the orientation lock is set to Landscape, that rotation can 505 // Tests that when the orientation lock is set to Landscape, that rotation can
493 // be done between the two angles of the orientation. 506 // be done between the two angles of the orientation.
494 TEST_F(ScreenOrientationControllerTest, LandscapeOrientationAllowsRotation) { 507 TEST_F(ScreenOrientationControllerTest, LandscapeOrientationAllowsRotation) {
495 scoped_ptr<content::WebContents> content(CreateWebContents()); 508 scoped_ptr<content::WebContents> content(CreateWebContents());
496 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 509 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
497 EnableMaximizeMode(true); 510 EnableMaximizeMode(true);
498 511
499 AttachAndActivateWebContents(content.get(), focus_window.get()); 512 AttachAndActivateWebContents(content.get(), focus_window.get());
500 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 513 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
501 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 514 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
502 EXPECT_TRUE(RotationLocked()); 515 EXPECT_TRUE(RotationLocked());
503 516
504 // Inverse of orientation is allowed 517 // Inverse of orientation is allowed
505 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 518 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
506 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 519 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
507 520
508 // Display rotations between are not allowed 521 // Display rotations between are not allowed
509 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); 522 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
510 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 523 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
511 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); 524 TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f));
512 EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); 525 EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation());
513 } 526 }
514 527
515 // Tests that when the orientation lock is set to Portrait, that rotaiton can be 528 // Tests that when the orientation lock is set to Portrait, that rotaiton can be
516 // done between the two angles of the orientation. 529 // done between the two angles of the orientation.
517 TEST_F(ScreenOrientationControllerTest, PortraitOrientationAllowsRotation) { 530 TEST_F(ScreenOrientationControllerTest, PortraitOrientationAllowsRotation) {
518 scoped_ptr<content::WebContents> content(CreateWebContents()); 531 scoped_ptr<content::WebContents> content(CreateWebContents());
519 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 532 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
520 EnableMaximizeMode(true); 533 EnableMaximizeMode(true);
521 534
522 AttachAndActivateWebContents(content.get(), focus_window.get()); 535 AttachAndActivateWebContents(content.get(), focus_window.get());
523 delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); 536 delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait);
524 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 537 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation());
525 EXPECT_TRUE(RotationLocked()); 538 EXPECT_TRUE(RotationLocked());
526 539
527 // Inverse of orientation is allowed 540 // Inverse of orientation is allowed
528 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); 541 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
529 EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 542 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
530 543
531 // Display rotations between are not allowed 544 // Display rotations between are not allowed
532 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 545 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
533 EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 546 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
534 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); 547 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f));
535 EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); 548 EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation());
536 } 549 }
537 550
538 // Tests that for an orientation lock which does not allow rotation, that the 551 // Tests that for an orientation lock which does not allow rotation, that the
539 // display rotation remains constant. 552 // display rotation remains constant.
540 TEST_F(ScreenOrientationControllerTest, OrientationLockDisallowsRotation) { 553 TEST_F(ScreenOrientationControllerTest, OrientationLockDisallowsRotation) {
541 scoped_ptr<content::WebContents> content(CreateWebContents()); 554 scoped_ptr<content::WebContents> content(CreateWebContents());
542 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 555 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
543 EnableMaximizeMode(true); 556 EnableMaximizeMode(true);
544 557
545 AttachAndActivateWebContents(content.get(), focus_window.get()); 558 AttachAndActivateWebContents(content.get(), focus_window.get());
546 delegate()->Lock(content.get(), 559 delegate()->Lock(content.get(),
547 blink::WebScreenOrientationLockPortraitPrimary); 560 blink::WebScreenOrientationLockPortraitPrimary);
548 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 561 EXPECT_EQ(gfx::Display::ROTATE_90, Rotation());
549 EXPECT_TRUE(RotationLocked()); 562 EXPECT_TRUE(RotationLocked());
550 563
551 // Rotation does not change. 564 // Rotation does not change.
552 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); 565 TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f));
553 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 566 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
554 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 567 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
555 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 568 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
556 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); 569 TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f));
557 EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); 570 EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation());
558 } 571 }
559 572
560 // Tests that after a content::WebContents has applied an orientation lock which 573 // Tests that after a content::WebContents has applied an orientation lock which
561 // supports rotation, that a user rotation lock does not allow rotation. 574 // supports rotation, that a user rotation lock does not allow rotation.
562 TEST_F(ScreenOrientationControllerTest, UserRotationLockDisallowsRotation) { 575 TEST_F(ScreenOrientationControllerTest, UserRotationLockDisallowsRotation) {
563 scoped_ptr<content::WebContents> content(CreateWebContents()); 576 scoped_ptr<content::WebContents> content(CreateWebContents());
564 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); 577 scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0));
565 EnableMaximizeMode(true); 578 EnableMaximizeMode(true);
566 579
567 AttachAndActivateWebContents(content.get(), focus_window.get()); 580 AttachAndActivateWebContents(content.get(), focus_window.get());
568 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); 581 delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape);
569 delegate()->Unlock(content.get()); 582 delegate()->Unlock(content.get());
570 583
571 SetRotationLocked(true); 584 SetRotationLocked(true);
572 EXPECT_TRUE(RotationLocked()); 585 EXPECT_TRUE(RotationLocked());
573 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 586 EXPECT_EQ(gfx::Display::ROTATE_0, Rotation());
574 587
575 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); 588 TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f));
576 EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); 589 EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation());
577 } 590 }
578 591
579 // Tests that when MaximizeMode is triggered before the internal display is 592 // Tests that when MaximizeMode is triggered before the internal display is
580 // ready, that ScreenOrientationController still begins listening to events, 593 // ready, that ScreenOrientationController still begins listening to events,
581 // which require an internal display to be acted upon. 594 // which require an internal display to be acted upon.
582 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) { 595 TEST_F(ScreenOrientationControllerTest, InternalDisplayNotAvailableAtStartup) {
583 int64 internal_display_id = gfx::Display::InternalDisplayId(); 596 int64 internal_display_id = gfx::Display::InternalDisplayId();
584 gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID); 597 gfx::Display::SetInternalDisplayId(gfx::Display::kInvalidDisplayID);
585 598
586 EnableMaximizeMode(true); 599 EnableMaximizeMode(true);
587 600
588 // Should not crash, even thought there is no internal display. 601 // Should not crash, even thought there is no internal display.
589 SetInternalDisplayRotation(gfx::Display::ROTATE_180); 602 SetInternalDisplayRotation(gfx::Display::ROTATE_180);
590 EXPECT_FALSE(RotationLocked()); 603 EXPECT_FALSE(RotationLocked());
591 604
592 // With an internal display now available, functionality should resume. 605 // With an internal display now available, functionality should resume.
593 gfx::Display::SetInternalDisplayId(internal_display_id); 606 gfx::Display::SetInternalDisplayId(internal_display_id);
594 SetInternalDisplayRotation(gfx::Display::ROTATE_90); 607 SetInternalDisplayRotation(gfx::Display::ROTATE_90);
595 EXPECT_TRUE(RotationLocked()); 608 EXPECT_TRUE(RotationLocked());
596 } 609 }
597 610
598 } // namespace ash 611 } // namespace ash
OLDNEW
« no previous file with comments | « ash/content/display/screen_orientation_controller_chromeos.cc ('k') | ash/display/display_controller.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698