Chromium Code Reviews| 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..ee32a436bb85ec4759feb12aefd0fb7091ef1409 |
| --- /dev/null |
| +++ b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/UseWideViewPortAction.java |
| @@ -0,0 +1,51 @@ |
| +// Copyright 2016 The Chromium Authors. All rights reserved. |
|
the real yoland
2016/11/15 01:45:44
similarly put this under webview_ui_test/test/util
aluo
2016/11/18 00:22:30
Done.
|
| +// 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; |
|
mikecase (-- gone --)
2016/11/15 00:50:50
nit: add empty line above the package line
aluo
2016/11/18 00:22:30
Done.
|
| + |
| +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 |
| + */ |
| +public class UseWideViewPortAction implements ViewAction { |
| + private boolean mUseWideViewPort; |
| + |
| + public UseWideViewPortAction() { |
|
mikecase (-- gone --)
2016/11/15 00:50:49
Should this be called SetUseWideViewportAction?
A
aluo
2016/11/18 00:22:30
Keeping it since this is a common case, changed na
|
| + 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. |
|
mikecase (-- gone --)
2016/11/15 00:50:50
Mention the view must be a WebView.
aluo
2016/11/18 00:22:30
Done.
|
| + */ |
| + @Override |
| + public void perform(UiController uiController, View view) { |
|
mikecase (-- gone --)
2016/11/15 00:50:50
maybe instead of the "never null" comment above, j
aluo
2016/11/18 00:22:30
Done.
|
| + WebView webview = (WebView) view; |
| + webview.getSettings().setUseWideViewPort(mUseWideViewPort); |
| + uiController.loopMainThreadUntilIdle(); |
| + } |
| +} |