summaryrefslogtreecommitdiffstats
path: root/android_webview
diff options
context:
space:
mode:
authorigsolla <igsolla@chromium.org>2014-12-18 10:14:50 -0800
committerCommit bot <commit-bot@chromium.org>2014-12-18 18:15:15 +0000
commit2404e06c634dac3406b5f42d64c01f7dbc817ed8 (patch)
treebd253d1c55037f7c986b509e1964e942fc276cfe /android_webview
parent7636e55dcf4ce092194ec2ab977e331a939c372b (diff)
downloadchromium_src-2404e06c634dac3406b5f42d64c01f7dbc817ed8.zip
chromium_src-2404e06c634dac3406b5f42d64c01f7dbc817ed8.tar.gz
chromium_src-2404e06c634dac3406b5f42d64c01f7dbc817ed8.tar.bz2
Fix some flakiness in AwContentsClientFullScreenTest.
The flakiness is due to the fact that the hole punching surface is created asynchronously after the video has started playback. Please see the comment by Hugo in the bug for more details. BUG=440774 Review URL: https://codereview.chromium.org/814853002 Cr-Commit-Position: refs/heads/master@{#309037}
Diffstat (limited to 'android_webview')
-rw-r--r--android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java33
1 files changed, 29 insertions, 4 deletions
diff --git a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
index a213195..5256e52 100644
--- a/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
+++ b/android_webview/javatests/src/org/chromium/android_webview/test/AwContentsClientFullScreenTest.java
@@ -35,6 +35,14 @@ import java.util.concurrent.TimeoutException;
* very common use case.
*/
public class AwContentsClientFullScreenTest extends AwTestBase {
+ /**
+ * MAX_WAIT_FOR_HOLE_PUNCHING_SURFACE_ATTACHED is used so that
+ * {@link #testHolePunchingSurfaceNotCreatedForClearVideo} provides a high level
+ * of confidence that the hole punching surface is not attached. By
+ * {@link #testOnShowCustomViewTransfersHolePunchingSurfaceForVideoInsideDiv}
+ * we know that it takes less that this time for the surface to be attached.
+ */
+ private static final long MAX_WAIT_FOR_HOLE_PUNCHING_SURFACE_ATTACHED = scaleTimeout(100);
private static final String VIDEO_TEST_URL =
"file:///android_asset/full_screen_video_test.html";
private static final String VIDEO_INSIDE_DIV_TEST_URL =
@@ -195,7 +203,8 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
// Note that VIDEO_TEST_URL contains clear video.
tapPlayButton();
assertTrue(DOMUtils.waitForVideoPlay(getWebContentsOnUiThread(), VIDEO_ID));
- assertContainsHolePunchingSurfaceView(mTestContainerView, false);
+ // Wait to ensure that the surface view is not added asynchronously.
+ waitAndAssertContainsHolePunchingSurfaceView(mTestContainerView, false);
}
@MediumTest
@@ -210,7 +219,7 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
// Play and verify that there is a surface view for hole punching.
tapPlayButton();
assertTrue(DOMUtils.waitForVideoPlay(getWebContentsOnUiThread(), VIDEO_ID));
- assertContainsHolePunchingSurfaceView(mTestContainerView, true);
+ assertWaitForContainsHolePunchingSurfaceView(mTestContainerView, true);
// Enter fullscreen and verify that the hole punching surface is transferred. Note
// that VIDEO_INSIDE_DIV_TEST_URL goes fullscreen on a <div> element, so in fullscreen
@@ -238,7 +247,7 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
// Play and verify that there is a surface view for hole punching.
tapPlayButton();
assertTrue(DOMUtils.waitForVideoPlay(getWebContentsOnUiThread(), VIDEO_ID));
- assertContainsHolePunchingSurfaceView(mTestContainerView, true);
+ assertWaitForContainsHolePunchingSurfaceView(mTestContainerView, true);
// Enter fullscreen and verify that the surface view is removed. Note that
// VIDEO_TEST_URL goes fullscreen on the <video> element, so in fullscreen
@@ -468,9 +477,25 @@ public class AwContentsClientFullScreenTest extends AwTestBase {
assertEquals(containsChildOfType(view, NoPunchingSurfaceView.class), expected);
}
+ private void assertWaitForContainsHolePunchingSurfaceView(
+ final View view, final boolean expected) throws InterruptedException {
+ assertTrue(CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return containsChildOfType(view, NoPunchingSurfaceView.class) == expected;
+ } catch (Exception e) {
+ fail(e.getMessage());
+ return false;
+ }
+ }
+ }, MAX_WAIT_FOR_HOLE_PUNCHING_SURFACE_ATTACHED,
+ MAX_WAIT_FOR_HOLE_PUNCHING_SURFACE_ATTACHED / 10));
+ }
+
private void waitAndAssertContainsHolePunchingSurfaceView(View view, boolean expected)
throws Exception {
- Thread.sleep(scaleTimeout(100));
+ Thread.sleep(MAX_WAIT_FOR_HOLE_PUNCHING_SURFACE_ATTACHED);
assertEquals(expected, containsChildOfType(view, NoPunchingSurfaceView.class));
}