| Index: android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/UseWideViewPortAction.java
|
| diff --git a/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/UseWideViewPortAction.java b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/UseWideViewPortAction.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..157562cc9c584c8609dc5f6cb0bf4c39fc5557ec
|
| --- /dev/null
|
| +++ b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/UseWideViewPortAction.java
|
| @@ -0,0 +1,53 @@
|
| +// 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;
|
| +
|
| +import static android.support.test.espresso.matcher.ViewMatchers.isAssignableFrom;
|
| +
|
| +import android.support.test.espresso.UiController;
|
| +import android.support.test.espresso.ViewAction;
|
| +import android.view.View;
|
| +import android.webkit.WebView;
|
| +
|
| +import org.hamcrest.Matcher;
|
| +
|
| +/**
|
| + * A ViewAction to set WebView's useWideViewPort setting
|
| + * TODO(aluo): This may belong in WebViewUiTestRule.java
|
| + */
|
| +public class UseWideViewPortAction implements ViewAction {
|
| + private boolean mUseWideViewPort;
|
| +
|
| + public UseWideViewPortAction() {
|
| + this(true);
|
| + }
|
| +
|
| + public UseWideViewPortAction(boolean useWideViewPort) {
|
| + mUseWideViewPort = useWideViewPort;
|
| + }
|
| +
|
| + @Override
|
| + public Matcher<View> getConstraints() {
|
| + return isAssignableFrom(WebView.class);
|
| + }
|
| +
|
| + @Override
|
| + public String getDescription() {
|
| + return "use wide viewport: " + mUseWideViewPort;
|
| + }
|
| +
|
| + /**
|
| + * Performs setUseWideViewPort then waits for completion.
|
| + *
|
| + * @param uiController the controller to use to interact with the UI.
|
| + * @param view the view to act upon. never null.
|
| + */
|
| + @Override
|
| + public void perform(UiController uiController, View view) {
|
| + WebView webview = (WebView) view;
|
| + webview.getSettings().setUseWideViewPort(mUseWideViewPort);
|
| + uiController.loopMainThreadUntilIdle();
|
| + }
|
| +}
|
|
|