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

Unified Diff: content/browser/screen_orientation/screen_orientation_provider_unittest.cc

Issue 2702033002: [ScreenOrientation] Fire pending lock request when we found it has failed.
Patch Set: Created 3 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: content/browser/screen_orientation/screen_orientation_provider_unittest.cc
diff --git a/content/browser/screen_orientation/screen_orientation_provider_unittest.cc b/content/browser/screen_orientation/screen_orientation_provider_unittest.cc
index 2a7a4e5410e9cccaf1af818005f128cde669840d..1b75b9f6c35065590b53cd51dfa35acf98f8b02a 100644
--- a/content/browser/screen_orientation/screen_orientation_provider_unittest.cc
+++ b/content/browser/screen_orientation/screen_orientation_provider_unittest.cc
@@ -150,8 +150,18 @@ TEST_F(ScreenOrientationProviderTest, DelegateLockOnce) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result_1);
- // Lock request is pending.
+#if defined(OS_ANDROID)
+ // On Android the screen orientation is expected to be changed asynchronously,
+ // the lock request is pending.
EXPECT_FALSE(result_1.has_value());
+#else
+ // On other platforms the screen orientation is expected to be changed
+ // synchronously, but FakeScreenOrientationDelegate did not change screen
+ // orientation actually, so the lock request will be fired immediately.
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result_1);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
}
@@ -187,8 +197,14 @@ TEST_F(ScreenOrientationProviderTest, DelegateRequireFullScreenLockOnce) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result_2);
+#if defined(OS_ANDROID)
// Lock request is pending.
EXPECT_FALSE(result_2.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result_2);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
}
@@ -206,8 +222,14 @@ TEST_F(ScreenOrientationProviderTest, DelegateLockThenUnlock) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result_1);
+#if defined(OS_ANDROID)
// The lock request will be pending.
EXPECT_FALSE(result_1.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result_1);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
EXPECT_EQ(0, delegate.unlock_count());
@@ -234,8 +256,14 @@ TEST_F(ScreenOrientationProviderTest, DelegateLockThenLock) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result_1);
+#if defined(OS_ANDROID)
// The lock request will be pending.
EXPECT_FALSE(result_1.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result_1);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
EXPECT_EQ(0, delegate.unlock_count());
@@ -248,8 +276,14 @@ TEST_F(ScreenOrientationProviderTest, DelegateLockThenLock) {
EXPECT_EQ(ScreenOrientationLockResult::
SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
result_1);
+#if defined(OS_ANDROID)
// The second one became pending.
EXPECT_FALSE(result_2.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result_2);
+#endif
// Delegate did apply lock once more.
EXPECT_EQ(2, delegate.lock_count());
EXPECT_EQ(0, delegate.unlock_count());
@@ -290,8 +324,14 @@ TEST_F(ScreenOrientationProviderTest, UnlockWhenExitingFullScreen) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result);
+#if defined(OS_ANDROID)
// The lock request will be pending.
EXPECT_FALSE(result.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
EXPECT_EQ(0, delegate.unlock_count());
@@ -323,8 +363,14 @@ TEST_F(ScreenOrientationProviderTest, UnlockWhenNavigation) {
CallLockAndGetResult(blink::WebScreenOrientationLockType::
WebScreenOrientationLockLandscapeSecondary,
&result);
+#if defined(OS_ANDROID)
// The lock request will be pending.
EXPECT_FALSE(result.has_value());
+#else
+ EXPECT_EQ(ScreenOrientationLockResult::
+ SCREEN_ORIENTATION_LOCK_RESULT_ERROR_CANCELED,
+ result);
+#endif
// Delegate did apply lock once.
EXPECT_EQ(1, delegate.lock_count());
EXPECT_EQ(0, delegate.unlock_count());
« no previous file with comments | « content/browser/screen_orientation/screen_orientation_provider.cc ('k') | content/browser/web_contents/web_contents_impl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698