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

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

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