Commit b6445d91 authored by mlamouri@chromium.org's avatar mlamouri@chromium.org

Test Screen Orientation polling for Android 4.0/4.1.

This is done by enabling "accurate mode" in tests and enabling the tests
to run on those platforms.

BUG=400158

Review URL: https://codereview.chromium.org/449833002

Cr-Commit-Position: refs/heads/master@{#288329}
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@288329 0039d316-1c4b-4281-b951-d872f2087c98
parent 35b177f4
...@@ -5,7 +5,6 @@ ...@@ -5,7 +5,6 @@
package org.chromium.content.browser; package org.chromium.content.browser;
import android.content.pm.ActivityInfo; import android.content.pm.ActivityInfo;
import android.os.Build;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
...@@ -82,6 +81,7 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -82,6 +81,7 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@Override @Override
public void run() { public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity); ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
ScreenOrientationListener.getInstance().startAccurateListening();
} }
}); });
...@@ -95,6 +95,7 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -95,6 +95,7 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@Override @Override
public void run() { public void run() {
getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED); getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
ScreenOrientationListener.getInstance().startAccurateListening();
} }
}); });
...@@ -122,13 +123,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -122,13 +123,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testFlipPortrait() throws Exception { public void testFlipPortrait() throws Exception {
// This can't work for pre JB-MR1 SDKs for the moment. We will whether
// disable the feature entirely on that platform or add an "accurate"
// mode.
// See http://crbug.com/400158
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return;
lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT); lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
assertEquals(0, mObserver.mOrientation); assertEquals(0, mObserver.mOrientation);
...@@ -140,13 +134,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -140,13 +134,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testFlipLandscape() throws Exception { public void testFlipLandscape() throws Exception {
// This can't work for pre JB-MR1 SDKs for the moment. We will whether
// disable the feature entirely on that platform or add an "accurate"
// mode.
// See http://crbug.com/400158
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return;
lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE); lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
assertEquals(90, mObserver.mOrientation); assertEquals(90, mObserver.mOrientation);
......
...@@ -4,7 +4,6 @@ ...@@ -4,7 +4,6 @@
package org.chromium.content.browser; package org.chromium.content.browser;
import android.os.Build;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ThreadUtils; import org.chromium.base.ThreadUtils;
...@@ -87,6 +86,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase { ...@@ -87,6 +86,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
@Override @Override
public void run() { public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity); ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
ScreenOrientationProvider.startAccurateListening();
} }
}); });
...@@ -103,6 +103,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase { ...@@ -103,6 +103,7 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
@Override @Override
public void run() { public void run() {
ScreenOrientationProvider.unlockOrientation(); ScreenOrientationProvider.unlockOrientation();
ScreenOrientationProvider.startAccurateListening();
} }
}); });
...@@ -129,14 +130,6 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase { ...@@ -129,14 +130,6 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testPortrait() throws Exception { public void testPortrait() throws Exception {
// Do not run that test for versions of Android before JB-MR1 because
// the ScreenOrientationListener for those versions isn't accurate
// enough. We will later simply not run that code in that version or add
// an "accurate mode" that will fix this by polling.
// See http://crbug.com/400158
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return;
lockOrientationAndWait(ScreenOrientationValues.PORTRAIT_PRIMARY); lockOrientationAndWait(ScreenOrientationValues.PORTRAIT_PRIMARY);
assertTrue(checkOrientationForLock(ScreenOrientationValues.PORTRAIT_PRIMARY)); assertTrue(checkOrientationForLock(ScreenOrientationValues.PORTRAIT_PRIMARY));
...@@ -157,14 +150,6 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase { ...@@ -157,14 +150,6 @@ public class ScreenOrientationProviderTest extends ContentShellTestBase {
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testLandscape() throws Exception { public void testLandscape() throws Exception {
// Do not run that test for versions of Android before JB-MR1 because
// the ScreenOrientationListener for those versions isn't accurate
// enough. We will later simply not run that code in that version or add
// an "accurate mode" that will fix this by polling.
// See http://crbug.com/400158
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return;
lockOrientationAndWait(ScreenOrientationValues.LANDSCAPE_PRIMARY); lockOrientationAndWait(ScreenOrientationValues.LANDSCAPE_PRIMARY);
assertTrue(checkOrientationForLock(ScreenOrientationValues.LANDSCAPE_PRIMARY)); assertTrue(checkOrientationForLock(ScreenOrientationValues.LANDSCAPE_PRIMARY));
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment