Commit 176fdcfa authored by peter@chromium.org's avatar peter@chromium.org

Revert of Re-enable ScreenOrientationListenerTest.java and run locking on UI...

Revert of Re-enable ScreenOrientationListenerTest.java and run locking on UI thread. (https://codereview.chromium.org/434693002/)

Reason for revert:
This broke the following test on the contentshell_instrumentation_tests
on the Android Tests (dbg):

ScreenOrientationListenerTest.testConfigurationListenerFlipLandscape

http://build.chromium.org/p/chromium.webkit/builders/Android%20Tests%20%28dbg%29/builds/20567/steps/contentshell_instrumentation_tests/logs/stdio

Original issue's description:
> Re-enable ScreenOrientationListenerTest.java and run locking on UI thread.
> 
> BUG=356483,354553
> 
> Committed: https://src.chromium.org/viewvc/chrome?view=rev&revision=287112

TBR=jdduke@chromium.org,mlamouri@chromium.org
NOTREECHECKS=true
NOTRY=true
BUG=356483,354553

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

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287210 0039d316-1c4b-4281-b951-d872f2087c98
parent cc9b29fb
...@@ -9,7 +9,6 @@ import android.os.Build; ...@@ -9,7 +9,6 @@ import android.os.Build;
import android.test.suitebuilder.annotation.MediumTest; import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest; import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature; import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils; import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.CriteriaHelper; import org.chromium.content.browser.test.util.CriteriaHelper;
...@@ -51,11 +50,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -51,11 +50,6 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
} }
} }
private void runOnUiThreadAndWait(Runnable runnable) {
ThreadUtils.runOnUiThreadBlocking(runnable);
getInstrumentation().waitForIdleSync();
}
/** /**
* Locks the screen orientation to the predefined orientation type. * Locks the screen orientation to the predefined orientation type.
*/ */
...@@ -67,20 +61,14 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -67,20 +61,14 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
* Locks the screen orientation to the predefined orientation type then wait * Locks the screen orientation to the predefined orientation type then wait
* for the orientation change to happen. * for the orientation change to happen.
*/ */
private void lockOrientationAndWait(final int orientation) throws InterruptedException { private boolean lockOrientationAndWait(int orientation)
runOnUiThreadAndWait(new Runnable() { throws InterruptedException {
@Override OrientationChangeObserverCriteria criteria = new OrientationChangeObserverCriteria(
public void run() { mObserver, orientationTypeToAngle(orientation));
try {
lockOrientation(orientation); lockOrientation(orientation);
} catch (Exception e) {
fail("Should not be there!"); return CriteriaHelper.pollForCriteria(criteria);
}
}
});
CriteriaHelper.pollForCriteria(
new OrientationChangeObserverCriteria(mObserver, orientationTypeToAngle(orientation)));
} }
/** /**
...@@ -107,22 +95,13 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -107,22 +95,13 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
} }
private void setUpForConfigurationListener() throws InterruptedException { private void setUpForConfigurationListener() throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ScreenOrientationListener.getInstance().injectConfigurationListenerBackendForTest();
@Override
public void run() { ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
ScreenOrientationListener.getInstance().injectConfigurationListenerBackendForTest();
}
});
final ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
waitForActiveShellToBeDoneLoading(); waitForActiveShellToBeDoneLoading();
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ScreenOrientationListener.getInstance().addObserver(
@Override mObserver, getInstrumentation().getTargetContext());
public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
}
});
} }
private boolean setUpForDisplayListener() throws InterruptedException { private boolean setUpForDisplayListener() throws InterruptedException {
...@@ -130,18 +109,40 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -130,18 +109,40 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1) if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return false; return false;
final ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL); ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
waitForActiveShellToBeDoneLoading(); waitForActiveShellToBeDoneLoading();
ThreadUtils.runOnUiThreadBlocking(new Runnable() { ScreenOrientationListener.getInstance().addObserver(
@Override mObserver, getInstrumentation().getTargetContext());
public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
}
});
return true; return true;
} }
// At least one of these tests flakes 50% on all runs of
// contentshell_instrumentation_tests.
// crbug.com/356483
/*
@SmallTest
@Feature({"ScreenOrientation"})
public void testConfigurationListenerDefault() throws Exception {
setUpForConfigurationListener();
assertFalse(mObserver.mHasChanged);
assertEquals(-1, mObserver.mOrientation);
}
@SmallTest
@Feature({"ScreenOrientation"})
public void testConfigurationListenerAsyncSetup() throws Exception {
setUpForConfigurationListener();
// We should get a onScreenOrientationChange call asynchronously.
CriteriaHelper.pollForCriteria(new OrientationChangeObserverCriteria(
mObserver));
assertTrue(mObserver.mHasChanged);
assertTrue(mObserver.mOrientation != -1);
}
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testConfigurationListenerChanges() throws Exception { public void testConfigurationListenerChanges() throws Exception {
...@@ -185,6 +186,28 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -185,6 +186,28 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
assertEquals(90, mObserver.mOrientation); assertEquals(90, mObserver.mOrientation);
} }
@SmallTest
@Feature({"ScreenOrientation"})
public void testDisplayListenerDefault() throws Exception {
if (!setUpForDisplayListener())
return;
assertEquals(-1, mObserver.mOrientation);
}
@SmallTest
@Feature({"ScreenOrientation"})
public void testDisplayListenerAsyncSetup() throws Exception {
if (!setUpForDisplayListener())
return;
// We should get a onScreenOrientationChange call asynchronously.
CriteriaHelper.pollForCriteria(new OrientationChangeObserverCriteria(
mObserver));
assertTrue(mObserver.mOrientation != -1);
}
@MediumTest @MediumTest
@Feature({"ScreenOrientation"}) @Feature({"ScreenOrientation"})
public void testDisplayListenerChanges() throws Exception { public void testDisplayListenerChanges() throws Exception {
...@@ -231,4 +254,5 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase { ...@@ -231,4 +254,5 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE); lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
assertEquals(-90, mObserver.mOrientation); assertEquals(-90, mObserver.mOrientation);
} }
*/
} }
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