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

Unified Diff: content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java

Issue 435193002: Speed-up ScreenOrientationListenerTest. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@screen_orientation_provider_tests
Patch Set: include various cleanups Created 6 years, 4 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java
diff --git a/content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java b/content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java
index d00e07256de701798f431da42815bab77ca22047..153e0af321d814fa8283e080bcc555324f9f09f7 100644
--- a/content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java
+++ b/content/public/android/javatests/src/org/chromium/content/browser/ScreenOrientationListenerTest.java
@@ -6,7 +6,6 @@ package org.chromium.content.browser;
import android.content.pm.ActivityInfo;
import android.os.Build;
-import android.test.suitebuilder.annotation.LargeTest;
import android.test.suitebuilder.annotation.MediumTest;
import org.chromium.base.ThreadUtils;
@@ -52,41 +51,22 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
}
/**
- * Locks the screen orientation to the predefined orientation type.
- */
- private void lockOrientation(int orientation) {
- getActivity().setRequestedOrientation(orientation);
- }
-
- /**
* Locks the screen orientation to the predefined orientation type then wait
* for the orientation change to happen.
*/
private void lockOrientationAndWait(final int orientation) throws InterruptedException {
+ OrientationChangeObserverCriteria criteria =
Peter Beverloo 2014/08/04 12:58:19 nit: maybe move this after the ThreadUtils.rOUTB c
mlamouri (slow - plz ping) 2014/08/04 14:32:47 This is actually the change making the test faster
+ new OrientationChangeObserverCriteria(mObserver,
+ orientationTypeToAngle(orientation));
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
- try {
- lockOrientation(orientation);
- } catch (Exception e) {
- fail("Should not be there!");
- }
+ getActivity().setRequestedOrientation(orientation);
}
});
- // TODO(mlamouri): this slows the tests down, we could consider removing
- // this if it doesn't flakes the test.
getInstrumentation().waitForIdleSync();
- CriteriaHelper.pollForCriteria(
- new OrientationChangeObserverCriteria(mObserver, orientationTypeToAngle(orientation)));
- }
-
- /**
- * Unlock the screen orientation. Equivalent to locking to unspecified.
- */
- private void unlockOrientation() {
- getActivity().setRequestedOrientation(
- ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ CriteriaHelper.pollForCriteria(criteria);
}
@Override
@@ -111,13 +91,18 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@Override
public void tearDown() throws Exception {
- unlockOrientation();
+ ThreadUtils.runOnUiThreadBlocking(new Runnable() {
+ @Override
+ public void run() {
+ getActivity().setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED);
+ }
+ });
mObserver = null;
super.tearDown();
}
- @LargeTest
+ @MediumTest
@Feature({"ScreenOrientation"})
public void testVariousOrientationChanges() throws Exception {
lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_LANDSCAPE);
@@ -137,7 +122,10 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@MediumTest
@Feature({"ScreenOrientation"})
public void testFlipPortrait() throws Exception {
- // This can't work for pre JB-MR1 SDKs.
+ // 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;
@@ -152,7 +140,10 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
@MediumTest
@Feature({"ScreenOrientation"})
public void testFlipLandscape() throws Exception {
- // This can't work for pre JB-MR1 SDKs.
+ // 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;
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698