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

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

Issue 2349663003: Adding WebView select tests to test select element's dropdown menu (Closed)
Patch Set: Addressed comments from mikecase@ 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/Actions.java
diff --git a/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Actions.java b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Actions.java
new file mode 100644
index 0000000000000000000000000000000000000000..bf2fecc085a0e33b78453c820b12a6445ad686ed
--- /dev/null
+++ b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/Actions.java
@@ -0,0 +1,82 @@
+// 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.matcher.ViewMatchers.isAssignableFrom;
+import static android.support.test.espresso.matcher.ViewMatchers.isDescendantOfA;
+import static android.support.test.espresso.matcher.ViewMatchers.withEffectiveVisibility;
+
+import static org.hamcrest.Matchers.allOf;
+
+import android.support.annotation.NonNull;
+import android.support.test.espresso.UiController;
+import android.support.test.espresso.ViewAction;
+import android.support.test.espresso.matcher.ViewMatchers;
+import android.view.View;
+import android.webkit.WebView;
+
+import org.hamcrest.Matcher;
+
+/**
+ * Actions to help with WebView tests
+ */
+public class Actions {
+
+ public static ViewAction setUseWideViewPort() {
+ return setUseWideViewPort(true);
+ }
+ public static ViewAction setUseWideViewPort(final boolean useWideViewPort) {
+ return new ViewAction() {
+ @Override
+ public Matcher<View> getConstraints() {
+ return isAssignableFrom(WebView.class);
+ }
+
+ @Override
+ public String getDescription() {
+ return "use wide viewport: " + useWideViewPort;
+ }
+
+ /**
+ * Performs setUseWideViewPort then waits for completion.
+ *
+ * @param uiController the controller to use to interact with the UI.
+ * @param view the view to act upon. Must be webview or a subclass thereof.
+ */
+ @Override
+ public void perform(UiController uiController, @NonNull View view) {
+ WebView webview = (WebView) view;
+ webview.getSettings().setUseWideViewPort(useWideViewPort);
+ uiController.loopMainThreadUntilIdle();
+ }
+ };
+ }
+ public static ViewAction scrollBy(final int x, final int y) {
+ return new ViewAction() {
+ @Override
+ public Matcher<View> getConstraints() {
+ return allOf(withEffectiveVisibility(ViewMatchers.Visibility.VISIBLE),
+ isDescendantOfA(isAssignableFrom(View.class)));
the real yoland 2016/12/16 18:04:42 nits: this is also only used for WebView?
+ }
+
+ @Override
+ public String getDescription() {
+ return "scroll by: " + x + "," + y;
+ }
+
+ /**
+ * Performs setUseWideViewPort then waits for completion.
+ *
+ * @param uiController the controller to use to interact with the UI.
+ * @param view the view to act upon.
+ */
+ @Override
+ public void perform(UiController uiController, @NonNull View view) {
+ view.scrollBy(x, y);
+ uiController.loopMainThreadUntilIdle();
+ }
+ };
+ }
+}

Powered by Google App Engine
This is Rietveld 408576698