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

Unified Diff: android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Atoms.java

Issue 2349663003: Adding WebView select tests to test select element's dropdown menu (Closed)
Patch Set: Add todo for UseWideViewPortAction Created 4 years 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: android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Atoms.java
diff --git a/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Atoms.java b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Atoms.java
new file mode 100644
index 0000000000000000000000000000000000000000..9f9cd01a9b40f2784f3d7f5391d80fa50c590374
--- /dev/null
+++ b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Atoms.java
@@ -0,0 +1,39 @@
+// Copyright 2016 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+package org.chromium.webview_ui_test.test.util;
+
+import static android.support.test.espresso.web.model.Atoms.castOrDie;
+
+import android.support.test.espresso.web.model.Atom;
+import android.support.test.espresso.web.model.Evaluation;
+import android.support.test.espresso.web.model.SimpleAtom;
+import android.support.test.espresso.web.model.TransformingAtom;
+
+/**
+ * A collection of Javascript Atoms for WebView testing
+ */
+public class Atoms {
+ /**
+ * Click on a select element in HTML
+ */
+ public static SimpleAtom webSelect() {
+ return new SimpleAtom(
+ "function(webElement) {"
+ + " var e = document.createEvent('MouseEvents');"
+ + " e.initMouseEvent('mousedown', true, true, window, 0, 0, 0, 0, 0,"
+ + " false, false, false, false, 0, null);"
+ + " webElement.dispatchEvent(e);"
+ + "}");
+ }
+
+ /**
+ * Returns an Atom that represents the text in the select element's currently selected item
+ */
+ public static Atom<String> currentSelection() {
+ return new TransformingAtom<Evaluation, String>(
+ new SimpleAtom("function(e) {return e.options[e.selectedIndex].text;}"),
+ castOrDie(String.class));
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698