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

Unified Diff: content/public/test/android/javatests/src/org/chromium/content/browser/test/util/DOMUtils.java

Issue 1110833004: Move audio focus control from media/ to content/ and make it per WebContents. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 7 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
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 418cb952cb00c946b4d02f7980e36bfd41cb4145..380de110a06821cf173b3528e9e3576418eff8b8 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,39 +22,76 @@ import java.util.concurrent.TimeoutException;
*/
public class DOMUtils {
/**
- * Pauses the video with given {@code nodeId}.
+ * Plays the media with given {@code id}.
*/
- public static void pauseVideo(final WebContents webContents, final String nodeId)
+ public static void playMedia(final WebContents webContents, final String id)
throws InterruptedException, TimeoutException {
StringBuilder sb = new StringBuilder();
sb.append("(function() {");
- sb.append(" var video = document.getElementById('" + nodeId + "');");
- sb.append(" if (video) video.pause();");
+ sb.append(" var media = document.getElementById('" + id + "');");
+ sb.append(" if (media) media.play();");
sb.append("})();");
JavaScriptUtils.executeJavaScriptAndWaitForResult(
webContents, sb.toString());
}
/**
- * Returns whether the video with given {@code nodeId} is paused.
+ * Pauses the media with given {@code id}.
*/
- public static boolean isVideoPaused(final WebContents webContents, final String nodeId)
+ public static void pauseMedia(final WebContents webContents, final String id)
throws InterruptedException, TimeoutException {
- return getNodeField("paused", webContents, nodeId, Boolean.class);
+ StringBuilder sb = new StringBuilder();
+ sb.append("(function() {");
+ sb.append(" var media = document.getElementById('" + id + "');");
+ sb.append(" if (media) media.pause();");
+ sb.append("})();");
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ webContents, sb.toString());
+ }
+
+ /**
+ * Returns whether the media with given {@code id} is paused.
+ */
+ public static boolean isMediaPaused(final WebContents webContents, final String id)
+ throws InterruptedException, TimeoutException {
+ return getNodeField("paused", webContents, id, Boolean.class);
+ }
+
+ /**
+ * Waits until the playback of the media with given {@code id} has started.
+ *
+ * @return Whether the playback has started.
+ */
+ public static boolean waitForMediaPlay(final WebContents webContents, final String id)
+ throws InterruptedException {
+ return CriteriaHelper.pollForCriteria(new Criteria() {
+ @Override
+ public boolean isSatisfied() {
+ try {
+ return !DOMUtils.isMediaPaused(webContents, id);
+ } catch (InterruptedException e) {
+ // Intentionally do nothing
+ return false;
+ } catch (TimeoutException e) {
+ // Intentionally do nothing
+ return false;
+ }
+ }
+ });
}
/**
- * Waits until the playback of the video with given {@code nodeId} has started.
+ * Waits until the playback of the media with given {@code id} has stopped.
*
* @return Whether the playback has started.
*/
- public static boolean waitForVideoPlay(final WebContents webContents, final String nodeId)
+ public static boolean waitForMediaPause(final WebContents webContents, final String id)
throws InterruptedException {
return CriteriaHelper.pollForCriteria(new Criteria() {
@Override
public boolean isSatisfied() {
try {
- return !DOMUtils.isVideoPaused(webContents, nodeId);
+ return DOMUtils.isMediaPaused(webContents, id);
} catch (InterruptedException e) {
// Intentionally do nothing
return false;

Powered by Google App Engine
This is Rietveld 408576698