Index: ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
diff --git a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
index 27ec3d609a0ea61d321317648372d6b9f1c01b4f..342e9585b8e2a104d96fbf366eb3bcf35735a74e 100644 |
--- a/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
+++ b/ash/content/display/screen_orientation_controller_chromeos_unittest.cc |
@@ -41,6 +41,20 @@ |
->EnableMaximizeModeWindowManager(enable); |
} |
+gfx::Display::Rotation GetInternalDisplayRotation() { |
+ return Shell::GetInstance() |
+ ->display_manager() |
+ ->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
+ .rotation(); |
+} |
+ |
+gfx::Display::Rotation Rotation() { |
+ return Shell::GetInstance() |
+ ->display_manager() |
+ ->GetDisplayInfo(gfx::Display::InternalDisplayId()) |
+ .rotation(); |
+} |
+ |
bool RotationLocked() { |
return Shell::GetInstance() |
->screen_orientation_controller() |
@@ -49,8 +63,7 @@ |
void SetInternalDisplayRotation(gfx::Display::Rotation rotation) { |
Shell::GetInstance()->display_manager()->SetDisplayRotation( |
- gfx::Display::InternalDisplayId(), rotation, |
- gfx::Display::ROTATION_SOURCE_USER); |
+ gfx::Display::InternalDisplayId(), rotation); |
} |
void SetRotationLocked(bool rotation_locked) { |
@@ -153,12 +166,12 @@ |
scoped_ptr<content::WebContents> content(CreateWebContents()); |
scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); |
ASSERT_NE(nullptr, content->GetNativeView()); |
- ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); |
ASSERT_FALSE(RotationLocked()); |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
EXPECT_TRUE(RotationLocked()); |
} |
@@ -167,12 +180,12 @@ |
scoped_ptr<content::WebContents> content(CreateWebContents()); |
scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); |
ASSERT_NE(nullptr, content->GetNativeView()); |
- ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); |
ASSERT_FALSE(RotationLocked()); |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
EXPECT_TRUE(RotationLocked()); |
delegate()->Unlock(content.get()); |
@@ -185,16 +198,16 @@ |
scoped_ptr<content::WebContents> content(CreateWebContents()); |
scoped_ptr<aura::Window> focus_window(CreateTestWindowInShellWithId(0)); |
ASSERT_NE(nullptr, content->GetNativeView()); |
- ASSERT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ ASSERT_EQ(gfx::Display::ROTATE_0, Rotation()); |
ASSERT_FALSE(RotationLocked()); |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
- EXPECT_TRUE(RotationLocked()); |
- |
- delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); |
+ EXPECT_TRUE(RotationLocked()); |
+ |
+ delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
} |
// Tests that orientation can only be set by the first content::WebContents that |
@@ -210,7 +223,7 @@ |
AttachWebContents(content2.get(), focus_window2.get()); |
delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); |
delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
} |
// Tests that only the content::WebContents that set a rotation lock can perform |
@@ -261,17 +274,17 @@ |
delegate()->Lock(content1.get(), blink::WebScreenOrientationLockLandscape); |
delegate()->Lock(content2.get(), blink::WebScreenOrientationLockPortrait); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
aura::client::ActivationClient* activation_client = |
Shell::GetInstance()->activation_client(); |
activation_client->ActivateWindow(focus_window2.get()); |
EXPECT_TRUE(RotationLocked()); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
activation_client->ActivateWindow(focus_window1.get()); |
EXPECT_TRUE(RotationLocked()); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
} |
// Tests that a rotation lock is removed when the setting window is hidden, and |
@@ -321,13 +334,13 @@ |
EnableMaximizeMode(true); |
// Now test rotating in all directions. |
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
} |
// Tests that low angles are ignored by the accelerometer (i.e. when the device |
@@ -335,15 +348,15 @@ |
TEST_F(ScreenOrientationControllerTest, RotationIgnoresLowAngles) { |
EnableMaximizeMode(true); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, -kMeanGravity)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(-2.0f, 0.0f, -kMeanGravity)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, 2.0f, -kMeanGravity)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(2.0f, 0.0f, -kMeanGravity)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, -2.0f, -kMeanGravity)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
} |
// Tests that the display will stick to the current orientation beyond the |
@@ -352,7 +365,7 @@ |
EnableMaximizeMode(true); |
gfx::Vector3dF gravity(0.0f, -kMeanGravity, 0.0f); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
// Turn past half-way point to next direction and rotation should remain |
// the same. |
@@ -360,14 +373,14 @@ |
gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
// Turn more and the screen should rotate. |
degrees = 70.0; |
gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
// Turn back just beyond the half-way point and the new rotation should |
// still be in effect. |
@@ -375,7 +388,7 @@ |
gravity.set_x(-sin(degrees * kDegreesToRadians) * kMeanGravity); |
gravity.set_y(-cos(degrees * kDegreesToRadians) * kMeanGravity); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
} |
// Tests that the display will stick to its current orientation when the |
@@ -390,11 +403,11 @@ |
-cos(degrees * kDegreesToRadians) * kMeanGravity, |
0.0f); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
SetRotationLocked(false); |
TriggerLidUpdate(gravity); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
} |
// The TrayDisplay class that is responsible for adding/updating MessageCenter |
@@ -416,10 +429,10 @@ |
// Make sure notifications are still displayed when |
// adjusting the screen rotation directly when in maximize mode |
- ASSERT_NE(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ ASSERT_NE(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
SetInternalDisplayRotation(gfx::Display::ROTATE_270); |
SetRotationLocked(false); |
- EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
EXPECT_EQ(1u, message_center->NotificationCount()); |
EXPECT_TRUE(message_center->HasPopupNotifications()); |
@@ -431,9 +444,9 @@ |
// Make sure notifications are blocked when adjusting the screen rotation |
// via the accelerometer while in maximize mode |
// Rotate the screen 90 degrees |
- ASSERT_NE(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ ASSERT_NE(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); |
- ASSERT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ ASSERT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
EXPECT_EQ(0u, message_center->NotificationCount()); |
EXPECT_FALSE(message_center->HasPopupNotifications()); |
@@ -444,11 +457,11 @@ |
SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
// Clear all notifications |
message_center->RemoveAllNotifications(false); |
- ASSERT_NE(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ ASSERT_NE(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
ASSERT_EQ(0u, message_center->NotificationCount()); |
ASSERT_FALSE(message_center->HasPopupNotifications()); |
SetInternalDisplayRotation(gfx::Display::ROTATE_180); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
EXPECT_EQ(1u, message_center->NotificationCount()); |
EXPECT_TRUE(message_center->HasPopupNotifications()); |
} |
@@ -460,10 +473,10 @@ |
EnableMaximizeMode(true); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
EnableMaximizeMode(false); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
} |
// Tests that if a user sets a display rotation that accelerometer rotation |
@@ -486,7 +499,7 @@ |
// maximize mode was activated. |
SetInternalDisplayRotation(gfx::Display::ROTATE_0); |
EnableMaximizeMode(false); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
} |
// Tests that when the orientation lock is set to Landscape, that rotation can |
@@ -498,18 +511,18 @@ |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), blink::WebScreenOrientationLockLandscape); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
EXPECT_TRUE(RotationLocked()); |
// Inverse of orientation is allowed |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
// Display rotations between are not allowed |
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(-kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_180, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_180, GetInternalDisplayRotation()); |
} |
// Tests that when the orientation lock is set to Portrait, that rotaiton can be |
@@ -521,18 +534,18 @@ |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), blink::WebScreenOrientationLockPortrait); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); |
EXPECT_TRUE(RotationLocked()); |
// Inverse of orientation is allowed |
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
// Display rotations between are not allowed |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_270, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_270, GetInternalDisplayRotation()); |
} |
// Tests that for an orientation lock which does not allow rotation, that the |
@@ -545,16 +558,16 @@ |
AttachAndActivateWebContents(content.get(), focus_window.get()); |
delegate()->Lock(content.get(), |
blink::WebScreenOrientationLockPortraitPrimary); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, Rotation()); |
EXPECT_TRUE(RotationLocked()); |
// Rotation does not change. |
TriggerLidUpdate(gfx::Vector3dF(kMeanGravity, 0.0f, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, -kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_90, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_90, GetInternalDisplayRotation()); |
} |
// Tests that after a content::WebContents has applied an orientation lock which |
@@ -570,10 +583,10 @@ |
SetRotationLocked(true); |
EXPECT_TRUE(RotationLocked()); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, Rotation()); |
TriggerLidUpdate(gfx::Vector3dF(0.0f, kMeanGravity, 0.0f)); |
- EXPECT_EQ(gfx::Display::ROTATE_0, GetCurrentInternalDisplayRotation()); |
+ EXPECT_EQ(gfx::Display::ROTATE_0, GetInternalDisplayRotation()); |
} |
// Tests that when MaximizeMode is triggered before the internal display is |