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

Commit d3e8c512 authored by Zemiao Zhu's avatar Zemiao Zhu Committed by Automerger Merge Worker
Browse files

Merge "Clear SearchView focus after selecting search history." am: 521eeff4

Original change: https://googleplex-android-review.googlesource.com/c/platform/packages/apps/DocumentsUI/+/12222459

Change-Id: Icd8f736598cc33541123896b7723751202469293
parents f06d75fe 521eeff4
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -150,7 +150,7 @@ public class SearchFragment extends Fragment{
        final String item = mHistoryList.get(position);
        mSearchViewManager.setHistorySearch();
        mSearchViewManager.setCurrentSearch(item);
        mSearchViewManager.restoreSearch(true);
        mSearchViewManager.restoreSearch(/* keepFocus= */ false);
    }

    private void dismiss() {
+8 −0
Original line number Diff line number Diff line
@@ -34,6 +34,7 @@ import android.content.Context;
import android.support.test.uiautomator.UiDevice;
import android.support.test.uiautomator.UiObject;
import android.support.test.uiautomator.UiObjectNotFoundException;
import android.support.test.uiautomator.UiSelector;
import android.view.View;

import androidx.recyclerview.R;
@@ -76,6 +77,13 @@ public class SearchBot extends Bots.BaseBot {
        clear.click();
    }

    // Click on the search history item with specified queryText, if exists.
    public void clickSearchHistory(String queryText) throws UiObjectNotFoundException {
        UiObject history = findSearchHistoryView();
        UiSelector historyItemSelector = new UiSelector().text(queryText);
        mDevice.findObject(history.getSelector().childSelector(historyItemSelector)).click();
    }

    public void setInputText(String query) throws UiObjectNotFoundException {
        onView(SEARCH_INPUT).perform(typeText(query));
    }
+18 −0
Original line number Diff line number Diff line
@@ -244,5 +244,23 @@ public class SearchViewUiTest extends ActivityTest<FilesActivity> {

        bots.search.assertInputExists(true);
        bots.search.assertInputFocused(true);
        bots.search.assertSearchHistoryVisible(true);
    }

    public void testSearchView_focusClearedAfterSelectingSearchHistory() throws Exception {
        String queryText = "history";
        bots.search.clickIcon();
        bots.search.setInputText(queryText);
        bots.keyboard.pressEnter();
        device.waitForIdle();

        bots.search.clickSearchViewClearButton();
        device.waitForIdle();
        bots.search.assertInputFocused(true);
        bots.search.assertSearchHistoryVisible(true);

        bots.search.clickSearchHistory(queryText);
        bots.search.assertInputFocused(false);
        bots.search.assertSearchHistoryVisible(false);
    }
}