| Index: android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/WebViewUiTestRule.java
|
| diff --git a/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/WebViewUiTestRule.java b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/WebViewUiTestRule.java
|
| index d60a16bdab2229d689d4135494d0b5a28bef2b07..c3e6a72c666ca5f8e9ac50d404ac94bd20c600ae 100644
|
| --- a/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/WebViewUiTestRule.java
|
| +++ b/android_webview/tools/automated_ui_tests/javatests/src/org/chromium/webview_ui_test/test/util/WebViewUiTestRule.java
|
| @@ -4,7 +4,21 @@
|
|
|
| package org.chromium.webview_ui_test.test.util;
|
|
|
| +import static android.support.test.espresso.matcher.RootMatchers.withDecorView;
|
| +import static android.support.test.espresso.matcher.ViewMatchers.hasDescendant;
|
| +import static android.support.test.espresso.matcher.ViewMatchers.isCompletelyDisplayed;
|
| +import static android.support.test.espresso.matcher.ViewMatchers.withChild;
|
| +import static android.support.test.espresso.matcher.ViewMatchers.withClassName;
|
| +import static android.support.test.espresso.matcher.ViewMatchers.withText;
|
| +
|
| +import static org.hamcrest.CoreMatchers.allOf;
|
| +import static org.hamcrest.Matchers.endsWith;
|
| +import static org.hamcrest.Matchers.hasItem;
|
| +
|
| import android.content.Intent;
|
| +import android.os.Build;
|
| +import android.support.test.espresso.BaseLayerComponent;
|
| +import android.support.test.espresso.DaggerBaseLayerComponent;
|
| import android.support.test.rule.ActivityTestRule;
|
| import android.webkit.WebView;
|
|
|
| @@ -25,6 +39,7 @@ public class WebViewUiTestRule extends ActivityTestRule<WebViewUiTestActivity> {
|
|
|
| private WebViewSyncWrapper mSyncWrapper;
|
| private String mLayout;
|
| + private BaseLayerComponent mBaseLayerComponent;
|
|
|
| public WebViewUiTestRule(Class<WebViewUiTestActivity> activityClass) {
|
| super(activityClass);
|
| @@ -81,4 +96,35 @@ public class WebViewUiTestRule extends ActivityTestRule<WebViewUiTestActivity> {
|
| Assert.fail(e.getMessage());
|
| }
|
| }
|
| +
|
| + public boolean isActionBarDisplayed() {
|
| + if (mBaseLayerComponent == null) mBaseLayerComponent = DaggerBaseLayerComponent.create();
|
| +
|
| + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
|
| + // For M and above
|
| + if (hasItem(withDecorView(withChild(allOf(
|
| + withClassName(endsWith("PopupBackgroundView")),
|
| + isCompletelyDisplayed())))).matches(
|
| + mBaseLayerComponent.activeRootLister().listActiveRoots())) {
|
| + return true;
|
| + }
|
| + } else {
|
| + // For L
|
| + if (hasItem(withDecorView(hasDescendant(allOf(
|
| + withClassName(endsWith("ActionMenuItemView")),
|
| + isCompletelyDisplayed())))).matches(
|
| + mBaseLayerComponent.activeRootLister().listActiveRoots())) {
|
| + return true;
|
| + }
|
| +
|
| + // Paste option is a popup on L
|
| + if (hasItem(withDecorView(withChild(withText("Paste")))).matches(
|
| + mBaseLayerComponent.activeRootLister().listActiveRoots())) {
|
| + return true;
|
| + }
|
| + }
|
| +
|
| +
|
| + return false;
|
| + }
|
| }
|
|
|