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

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

Issue 639413002: [aw] Reuse WebContents PowerSaveBlocker in fullscreen. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@testsForPowerSaver
Patch Set: Nits Created 6 years, 2 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
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 46874fd4d2cb6a588400409d55a9ab1b52ccccfe..a8967baa93eeb17ad3c0be38f9a58b06fa53522d 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
@@ -21,26 +21,40 @@ import java.util.concurrent.TimeoutException;
* Collection of DOM-based utilities.
*/
public class DOMUtils {
+ /**
+ * Pauses the video with given {@code nodeId}.
+ */
+ public static void pauseVideo(final WebContents webContents, final String nodeId)
+ 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("})();");
+ JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ webContents, sb.toString());
+ }
/**
- * Returns whether the video with given {@code nodeId} has ended.
+ * Returns whether the video with given {@code nodeId} is paused.
*/
- public static boolean hasVideoEnded(final WebContents webContents, final String nodeId)
+ public static boolean isVideoPaused(final WebContents webContents, final String nodeId)
throws InterruptedException, TimeoutException {
- return getNodeField("ended", webContents, nodeId, Boolean.class);
+ return getNodeField("paused", webContents, nodeId, Boolean.class);
}
/**
- * Wait until the end of the video with given {@code nodeId}.
- * @return Whether the video has ended.
+ * Waits until the playback of the video with given {@code nodeId} has started.
+ *
+ * @return Whether the playback has started.
*/
- public static boolean waitForEndOfVideo(final WebContents webContents, final String nodeId)
+ public static boolean waitForVideoPlay(final WebContents webContents, final String nodeId)
throws InterruptedException {
return CriteriaHelper.pollForCriteria(new Criteria() {
@Override
public boolean isSatisfied() {
try {
- return DOMUtils.hasVideoEnded(webContents, nodeId);
+ return !DOMUtils.isVideoPaused(webContents, nodeId);
} catch (InterruptedException e) {
// Intentionally do nothing
return false;
@@ -53,6 +67,21 @@ public class DOMUtils {
}
/**
+ * Returns whether the document is in fullscreen.
+ */
+ public static boolean isFullscreen(final WebContents webContents)
+ throws InterruptedException, TimeoutException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(function() {");
+ sb.append(" return [document.webkitIsFullScreen];");
+ sb.append("})();");
+
+ String jsonText = JavaScriptUtils.executeJavaScriptAndWaitForResult(
+ webContents, sb.toString());
+ return readValue(jsonText, Boolean.class);
+ }
+
+ /**
* Makes the document exit fullscreen.
*/
public static void exitFullscreen(final WebContents webContents) {
@@ -193,7 +222,10 @@ public class DOMUtils {
webContents, sb.toString());
Assert.assertFalse("Failed to retrieve contents for " + nodeId,
jsonText.trim().equalsIgnoreCase("null"));
+ return readValue(jsonText, valueType);
+ }
+ private static <T> T readValue(String jsonText, Class<T> valueType) {
JsonReader jsonReader = new JsonReader(new StringReader(jsonText));
T value = null;
try {
« no previous file with comments | « content/public/common/content_switches.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698