Loading src/com/android/documentsui/queries/SearchFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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() { Loading tests/common/com/android/documentsui/bots/SearchBot.java +8 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); } Loading tests/functional/com/android/documentsui/SearchViewUiTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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); } } Loading
src/com/android/documentsui/queries/SearchFragment.java +1 −1 Original line number Diff line number Diff line Loading @@ -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() { Loading
tests/common/com/android/documentsui/bots/SearchBot.java +8 −0 Original line number Diff line number Diff line Loading @@ -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; Loading Loading @@ -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)); } Loading
tests/functional/com/android/documentsui/SearchViewUiTest.java +18 −0 Original line number Diff line number Diff line Loading @@ -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); } }