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;
import android.test.suitebuilder.annotation.MediumTest;
import android.test.suitebuilder.annotation.SmallTest;
import org.chromium.base.ThreadUtils;
import org.chromium.base.test.util.Feature;
import org.chromium.base.test.util.UrlUtils;
import org.chromium.content.browser.test.util.CriteriaHelper;
......@@ -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.
*/
......@@ -67,20 +61,14 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
* 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 {
runOnUiThreadAndWait(new Runnable() {
@Override
public void run() {
try {
private boolean lockOrientationAndWait(int orientation)
throws InterruptedException {
OrientationChangeObserverCriteria criteria = new OrientationChangeObserverCriteria(
mObserver, orientationTypeToAngle(orientation));
lockOrientation(orientation);
} catch (Exception e) {
fail("Should not be there!");
}
}
});
CriteriaHelper.pollForCriteria(
new OrientationChangeObserverCriteria(mObserver, orientationTypeToAngle(orientation)));
return CriteriaHelper.pollForCriteria(criteria);
}
/**
......@@ -107,22 +95,13 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
}
private void setUpForConfigurationListener() throws InterruptedException {
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
ScreenOrientationListener.getInstance().injectConfigurationListenerBackendForTest();
}
});
final ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
waitForActiveShellToBeDoneLoading();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
}
});
ScreenOrientationListener.getInstance().addObserver(
mObserver, getInstrumentation().getTargetContext());
}
private boolean setUpForDisplayListener() throws InterruptedException {
......@@ -130,18 +109,40 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR1)
return false;
final ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
ContentShellActivity activity = launchContentShellWithUrl(DEFAULT_URL);
waitForActiveShellToBeDoneLoading();
ThreadUtils.runOnUiThreadBlocking(new Runnable() {
@Override
public void run() {
ScreenOrientationListener.getInstance().addObserver(mObserver, activity);
}
});
ScreenOrientationListener.getInstance().addObserver(
mObserver, getInstrumentation().getTargetContext());
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
@Feature({"ScreenOrientation"})
public void testConfigurationListenerChanges() throws Exception {
......@@ -185,6 +186,28 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
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
@Feature({"ScreenOrientation"})
public void testDisplayListenerChanges() throws Exception {
......@@ -231,4 +254,5 @@ public class ScreenOrientationListenerTest extends ContentShellTestBase {
lockOrientationAndWait(ActivityInfo.SCREEN_ORIENTATION_REVERSE_LANDSCAPE);
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