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

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

Issue 1143443002: Use polling to check focused node instead of sleep. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add focus check for another test 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
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java ('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 235e4a3f391c88a56fafd732effbc803cce4794c..418cb952cb00c946b4d02f7980e36bfd41cb4145 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
@@ -153,6 +153,27 @@ public class DOMUtils {
}
/**
+ * Get the id of the currently focused node.
+ */
+ public static String getFocusedNode(WebContents webContents)
+ throws InterruptedException, TimeoutException {
+ StringBuilder sb = new StringBuilder();
+ sb.append("(function() {");
+ sb.append(" var node = document.activeElement;");
+ sb.append(" if (!node) return null;");
+ sb.append(" return node.id;");
+ sb.append("})();");
+
+ String id = JavaScriptUtils.executeJavaScriptAndWaitForResult(webContents, sb.toString());
+
+ // String results from JavaScript includes surrounding quotes. Remove them.
+ if (id != null && id.length() >= 2 && id.charAt(0) == '"') {
+ id = id.substring(1, id.length() - 1);
+ }
+ return id;
+ }
+
+ /**
* Click a DOM node by its id.
*/
public static void clickNode(ActivityInstrumentationTestCase2 activityTestCase,
« no previous file with comments | « content/public/android/javatests/src/org/chromium/content/browser/input/ImeTest.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698