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

Commit d9edfd08 authored by Android Build Coastguard Worker's avatar Android Build Coastguard Worker
Browse files

Snap for 13551643 from abb27a5c to 25Q3-release

Change-Id: Ib640f4e2968636421779e5ba6789641e5e9066d5
parents 20714dcb abb27a5c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -28,6 +28,7 @@
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:titleEnabled="false"
        app:contentScrim="@android:color/transparent"
        app:layout_scrollFlags="scroll|enterAlways|enterAlwaysCollapsed">

        <LinearLayout
+2 −5
Original line number Diff line number Diff line
@@ -317,11 +317,8 @@ public class SearchViewManager implements

                @Override
                public void onTextChanged(CharSequence s, int start, int before, int count) {
                    if (!s.isEmpty()) {
                        dockedSearchClear.setVisibility(View.VISIBLE);
                    } else {
                        dockedSearchClear.setVisibility(View.INVISIBLE);
                    }
                    dockedSearchClear.setVisibility(
                            TextUtils.isEmpty(s) ? View.INVISIBLE : View.VISIBLE);
                    onQueryTextChange(s.toString());
                }

+7 −13
Original line number Diff line number Diff line
@@ -16,6 +16,8 @@

package com.android.documentsui.bots;

import static androidx.test.espresso.Espresso.onView;
import static androidx.test.espresso.action.ViewActions.typeText;
import static androidx.test.espresso.matcher.ViewMatchers.hasDescendant;
import static androidx.test.espresso.matcher.ViewMatchers.isClickable;
import static androidx.test.espresso.matcher.ViewMatchers.isDisplayed;
@@ -35,7 +37,6 @@ import androidx.test.uiautomator.By;
import androidx.test.uiautomator.BySelector;
import androidx.test.uiautomator.UiDevice;
import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiObject2;
import androidx.test.uiautomator.UiObjectNotFoundException;
import androidx.test.uiautomator.UiSelector;
import androidx.test.uiautomator.Until;
@@ -58,14 +59,6 @@ public class SearchBot extends Bots.BaseBot {
            withId(R.id.option_menu_search),
            anyOf(isClickable(), hasDescendant(isClickable())));

    // Note that input is visible when the clicky button is not
    // present. So to clearly qualify the two...we explicitly
    // require this input be not clickable.
    @SuppressWarnings("unchecked")
    private static final Matcher<View> SEARCH_INPUT = allOf(
            withId(androidx.appcompat.R.id.search_src_text),
            isDisplayed());

    public SearchBot(UiDevice device, Context context, int timeout) {
        super(device, context, timeout);
    }
@@ -101,12 +94,13 @@ public class SearchBot extends Bots.BaseBot {
    public void setInputText(String query) throws UiObjectNotFoundException {
        if (!showsDockedSearch()) {
            BySelector selector = By.res(mTargetPackage + ":id/search_src_text");
            UiObject2 searchInput = mDevice.wait(Until.findObject(selector), 5000);
            searchInput.setText(query);
            mDevice.wait(Until.findObject(selector), 5000);
            onView(allOf(withId(androidx.appcompat.R.id.search_src_text), isDisplayed()))
                    .perform(typeText(query));
        } else {
            BySelector selector = By.res(mTargetPackage + ":id/docked_search_text");
            UiObject2 searchInput = mDevice.wait(Until.findObject(selector), 5000);
            searchInput.setText(query);
            mDevice.wait(Until.findObject(selector), 5000);
            onView(allOf(withId(R.id.docked_search_text), isDisplayed())).perform(typeText(query));
        }
    }

+36 −7
Original line number Diff line number Diff line
@@ -31,6 +31,10 @@ import com.android.documentsui.picker.TrampolineActivity
import com.android.documentsui.rules.CheckAndForceMaterial3Flag
import java.util.Optional
import java.util.regex.Pattern
import kotlin.time.Duration.Companion.seconds
import kotlinx.coroutines.delay
import kotlinx.coroutines.runBlocking
import kotlinx.coroutines.withTimeoutOrNull
import org.junit.Assert.assertNotNull
import org.junit.Before
import org.junit.BeforeClass
@@ -59,15 +63,36 @@ class TrampolineActivityTest() {

        private lateinit var device: UiDevice

        fun removePhotopickerAndDocumentsUITasks() {
        suspend fun removePhotopickerAndDocumentsUITasks() {
            var taskIds = findPhotopickerAndDocumentsUITasks()

            for (taskId in taskIds) {
                device.executeShellCommand("am stack remove $taskId")
            }

            withTimeoutOrNull(5.seconds) {
                while (taskIds.isNotEmpty()) {
                    delay(100)
                    taskIds = findPhotopickerAndDocumentsUITasks()
                }
                true
            }
        }

        private fun findPhotopickerAndDocumentsUITasks(): Set<String> {
            // Get the current list of tasks that are visible.
            val result = device.executeShellCommand("am stack list")

            // Identify any that are from DocumentsUI or Photopicker and close them.
            val matcher = STACK_LIST_REGEX.matcher(result)

            val taskIds = mutableSetOf<String>()
            while (matcher.find()) {
                device.executeShellCommand("am stack remove ${matcher.group("taskId")}")
                val taskId = matcher.group("taskId")
                taskIds.add(taskId)
            }

            return taskIds
        }

        @BeforeClass
@@ -156,8 +181,13 @@ class TrampolineActivityTest() {

        @Before
        fun setUp() {
            runBlocking {
                removePhotopickerAndDocumentsUITasks()
            }
        }

        @Test
        fun testCorrectAppIsLaunched() {
            val context = InstrumentationRegistry.getInstrumentation().targetContext
            val intent = Intent(ACTION_GET_CONTENT)
            intent.setClass(context, TrampolineActivity::class.java)
@@ -168,10 +198,7 @@ class TrampolineActivityTest() {
            }

            context.startActivity(intent)
        }

        @Test
        fun testCorrectAppIsLaunched() {
            val bySelector = when (testData.expectedApp) {
                AppType.PHOTOPICKER -> By.pkg(PHOTOPICKER_PACKAGE_REGEX)
                else -> By.pkg(DOCUMENTSUI_PACKAGE_REGEX)
@@ -205,8 +232,10 @@ class TrampolineActivityTest() {

        @Before
        fun setUp() {
            runBlocking {
                removePhotopickerAndDocumentsUITasks()
            }
        }

        @Test
        fun testReferredGetContentFromPhotopickerShouldNotRedirectBack() {
+29 −1
Original line number Diff line number Diff line
@@ -19,17 +19,20 @@ package com.android.documentsui.picker;
import static com.android.documentsui.base.State.ACTION_CREATE;
import static com.android.documentsui.base.State.ACTION_GET_CONTENT;
import static com.android.documentsui.base.State.ACTION_OPEN;
import static com.android.documentsui.flags.Flags.FLAG_USE_MATERIAL3;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import android.annotation.SuppressLint;
import android.database.MatrixCursor;
import android.platform.test.annotations.RequiresFlagsDisabled;
import android.platform.test.annotations.RequiresFlagsEnabled;
import android.provider.DocumentsContract.Document;
import android.provider.DocumentsContract.Root;

import androidx.test.ext.junit.runners.AndroidJUnit4;
import androidx.test.filters.SmallTest;
import androidx.test.runner.AndroidJUnit4;

import com.android.documentsui.DirectoryResult;
import com.android.documentsui.Model;
@@ -38,6 +41,7 @@ import com.android.documentsui.base.DocumentInfo;
import com.android.documentsui.base.RootInfo;
import com.android.documentsui.base.State;
import com.android.documentsui.roots.RootCursorWrapper;
import com.android.documentsui.rules.CheckAndForceMaterial3Flag;
import com.android.documentsui.testing.TestDirectoryDetails;
import com.android.documentsui.testing.TestFeatures;
import com.android.documentsui.testing.TestMenu;
@@ -46,6 +50,7 @@ import com.android.documentsui.testing.TestSearchViewManager;
import com.android.documentsui.testing.TestSelectionDetails;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

@@ -53,6 +58,9 @@ import org.junit.runner.RunWith;
@SmallTest
public final class MenuManagerTest {

    @Rule
    public final CheckAndForceMaterial3Flag mCheckFlagsRule = new CheckAndForceMaterial3Flag();

    private TestMenu testMenu;

    /* Directory Context Menu items */
@@ -208,6 +216,7 @@ public final class MenuManagerTest {
    }

    @Test
    @RequiresFlagsDisabled(FLAG_USE_MATERIAL3)
    public void testActionMenu_selectAction() {
        state.action = ACTION_OPEN;
        mgr.updateActionMenu(testMenu, selectionDetails);
@@ -215,6 +224,15 @@ public final class MenuManagerTest {
        actionModeSelect.assertEnabledAndVisible();
    }

    @Test
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    public void testActionMenu_selectAction_useMaterial3Enabled() {
        state.action = ACTION_OPEN;
        mgr.updateActionMenu(testMenu, selectionDetails);

        actionModeSelect.assertDisabledAndInvisible();
    }

    @Test
    public void testActionMenu_selectActionTitle() {
        state.action = ACTION_OPEN;
@@ -224,6 +242,7 @@ public final class MenuManagerTest {
    }

    @Test
    @RequiresFlagsDisabled(FLAG_USE_MATERIAL3)
    public void testActionMenu_getContentAction() {
        state.action = ACTION_GET_CONTENT;
        mgr.updateActionMenu(testMenu, selectionDetails);
@@ -231,6 +250,15 @@ public final class MenuManagerTest {
        actionModeSelect.assertEnabledAndVisible();
    }

    @Test
    @RequiresFlagsEnabled(FLAG_USE_MATERIAL3)
    public void testActionMenu_getContentAction_useMaterial3Enabled() {
        state.action = ACTION_GET_CONTENT;
        mgr.updateActionMenu(testMenu, selectionDetails);

        actionModeSelect.assertDisabledAndInvisible();
    }

    @Test
    public void testActionMenu_getContentActionTitle() {
        state.action = ACTION_GET_CONTENT;