| Index: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java
|
| diff --git a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java
|
| index 235e4a3f391c88a56fafd732effbc803cce4794c..a1d5836605dcf9323497d340517af39054732a4b 100644
|
| --- a/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java
|
| +++ b/content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java
|
| @@ -22,6 +22,16 @@ import java.util.concurrent.TimeoutException;
|
| */
|
| public class DOMUtils {
|
| /**
|
| + * Video element is playing.
|
| + */
|
| + public static final int VIDEO_STATE_PLAYING = 0;
|
| +
|
| + /**
|
| + * Video element is paused.
|
| + */
|
| + public static final int VIDEO_STATE_PAUSED = 1;
|
| +
|
| + /**
|
| * Pauses the video with given {@code nodeId}.
|
| */
|
| public static void pauseVideo(final WebContents webContents, final String nodeId)
|
| @@ -44,17 +54,26 @@ public class DOMUtils {
|
| }
|
|
|
| /**
|
| - * Waits until the playback of the video with given {@code nodeId} has started.
|
| + * Waits until the playback of the video with given {@code nodeId} is {@code videoState}.
|
| *
|
| - * @return Whether the playback has started.
|
| + * @return Whether the playback state is now {@code videoState}.
|
| */
|
| - public static boolean waitForVideoPlay(final WebContents webContents, final String nodeId)
|
| + public static boolean waitForVideoState(final WebContents webContents,
|
| + final String nodeId, final int videoState)
|
| throws InterruptedException {
|
| return CriteriaHelper.pollForCriteria(new Criteria() {
|
| @Override
|
| public boolean isSatisfied() {
|
| try {
|
| - return !DOMUtils.isVideoPaused(webContents, nodeId);
|
| + switch (videoState) {
|
| + case VIDEO_STATE_PLAYING:
|
| + return !DOMUtils.isVideoPaused(webContents, nodeId);
|
| + case VIDEO_STATE_PAUSED:
|
| + return DOMUtils.isVideoPaused(webContents, nodeId);
|
| + default:
|
| + throw new IllegalArgumentException(
|
| + "Cannot wait for videoState: " + videoState);
|
| + }
|
| } catch (InterruptedException e) {
|
| // Intentionally do nothing
|
| return false;
|
|
|