Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit a29ef006 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "Fix atest DocumentsUIGoogleTests fails"

parents b9b8ad37 3432919d
Loading
Loading
Loading
Loading
+0 −2
Original line number Diff line number Diff line
@@ -58,8 +58,6 @@ import java.util.function.Predicate;
 */
public class BreadBot extends Bots.BaseBot {

    public static final String TARGET_PKG = "com.android.documentsui";

    private static final Matcher<View> DROPDOWN_BREADCRUMB = withId(
            R.id.dropdown_breadcrumb);

+9 −6
Original line number Diff line number Diff line
@@ -37,6 +37,7 @@ import android.support.test.uiautomator.UiObjectNotFoundException;
import android.view.View;

import androidx.recyclerview.R;
import androidx.test.InstrumentationRegistry;

import org.hamcrest.Matcher;

@@ -48,7 +49,7 @@ import org.hamcrest.Matcher;
 */
public class SearchBot extends Bots.BaseBot {

    public static final String TARGET_PKG = "com.android.documentsui";
    private final String mTargetPackage;

    // Dumb search layout changes substantially between Ryu and Angler.
    @SuppressWarnings("unchecked")
@@ -66,6 +67,8 @@ public class SearchBot extends Bots.BaseBot {

    public SearchBot(UiDevice device, Context context, int timeout) {
        super(device, context, timeout);
        mTargetPackage =
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName();
    }

    public void clickIcon() throws UiObjectNotFoundException {
@@ -112,18 +115,18 @@ public class SearchBot extends Bots.BaseBot {
    }

    private UiObject findSearchView() {
        return findObject("com.android.documentsui:id/option_menu_search");
        return findObject(mTargetPackage + ":id/option_menu_search");
    }

    private UiObject findSearchViewTextField() {
        return findObject("com.android.documentsui:id/option_menu_search",
                "com.android.documentsui:id/search_src_text");
        return findObject(mTargetPackage + ":id/option_menu_search",
                mTargetPackage + ":id/search_src_text");
    }

    private UiObject findSearchViewIcon() {
        return mContext.getResources().getBoolean(R.bool.full_bar_search_view)
                ? findObject("com.android.documentsui:id/option_menu_search")
                : findObject("com.android.documentsui:id/option_menu_search",
                ? findObject(mTargetPackage + ":id/option_menu_search")
                : findObject(mTargetPackage + ":id/option_menu_search",
                        "android:id/search_button");
    }
}
+4 −1
Original line number Diff line number Diff line
@@ -45,6 +45,7 @@ import android.util.TypedValue;
import android.view.View;

import androidx.appcompat.widget.Toolbar;
import androidx.test.InstrumentationRegistry;
import androidx.test.espresso.Espresso;
import androidx.test.espresso.action.ViewActions;
import androidx.test.espresso.matcher.BoundedMatcher;
@@ -66,7 +67,7 @@ import java.util.List;
 */
public class UiBot extends Bots.BaseBot {

    public static final String TARGET_PKG = "com.android.documentsui";
    public static String targetPackageName;

    @SuppressWarnings("unchecked")
    private static final Matcher<View> TOOLBAR = allOf(
@@ -93,6 +94,8 @@ public class UiBot extends Bots.BaseBot {

    public UiBot(UiDevice device, Context context, int timeout) {
        super(device, context, timeout);
        targetPackageName =
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName();
    }

    public void assertWindowTitle(String expected) {
+8 −4
Original line number Diff line number Diff line
@@ -31,6 +31,8 @@ import android.widget.ProgressBar;
import android.widget.RemoteViews;
import android.util.Log;

import androidx.test.InstrumentationRegistry;

/**
* This class receives a callback when Notification is posted or removed
* and monitors the Notification status.
@@ -58,13 +60,13 @@ public class TestNotificationService extends NotificationListenerService {
    public static final String EXTRA_ERROR_REASON =
            "com.android.documentsui.services.TestNotificationService.EXTRA_ERROR_REASON";

    private final static String DOCUMENTSUI_PACKAGE= "com.android.documentsui";

    public enum MODE {
        CANCEL_MODE,
        EXECUTION_MODE;
    }

    private static String mTargetPackageName;

    private MODE mCurrentMode = MODE.CANCEL_MODE;

    private boolean mCancelled = false;
@@ -87,6 +89,8 @@ public class TestNotificationService extends NotificationListenerService {

    @Override
    public void onCreate() {
        mTargetPackageName =
                InstrumentationRegistry.getInstrumentation().getTargetContext().getPackageName();
        mFrameLayout = new FrameLayout(getBaseContext());
        IntentFilter filter = new IntentFilter();
        filter.addAction(ACTION_CHANGE_CANCEL_MODE);
@@ -110,7 +114,7 @@ public class TestNotificationService extends NotificationListenerService {
    @Override
    public void onNotificationPosted(StatusBarNotification sbn) {
        String pkgName = sbn.getPackageName();
        if (DOCUMENTSUI_PACKAGE.equals(pkgName)) {
        if (mTargetPackageName.equals(pkgName)) {
            if (MODE.CANCEL_MODE.equals(mCurrentMode)) {
                try {
                    mCancelled = doCancel(sbn.getNotification());
@@ -124,7 +128,7 @@ public class TestNotificationService extends NotificationListenerService {
    @Override
    public void onNotificationRemoved(StatusBarNotification sbn) {
        String pkgName = sbn.getPackageName();
        if (!DOCUMENTSUI_PACKAGE.equals(pkgName)) {
        if (!mTargetPackageName.equals(pkgName)) {
            return;
        }

+1 −1
Original line number Diff line number Diff line
@@ -146,7 +146,7 @@ public abstract class ActivityTest<T extends Activity> extends ActivityInstrumen

    protected void launchActivity() {
        final Intent intent = context.getPackageManager().getLaunchIntentForPackage(
                UiBot.TARGET_PKG);
                UiBot.targetPackageName);
        intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK);
        if (getInitialRoot() != null) {
            intent.setAction(Intent.ACTION_VIEW);
Loading