diff --git a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java index 8d3a631744..4be46ab621 100644 --- a/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java +++ b/tests/tapl/com/android/launcher3/tapl/SearchResultFromQsb.java @@ -17,6 +17,7 @@ package com.android.launcher3.tapl; import static com.android.launcher3.testing.shared.TestProtocol.NORMAL_STATE_ORDINAL; +import android.text.TextUtils; import android.widget.TextView; import androidx.test.uiautomator.By; @@ -117,4 +118,28 @@ public class SearchResultFromQsb implements SearchInputSource { public SearchResultFromQsb getSearchResultForInput() { return this; } + + /** Verify a tile is present by checking its title and subtitle. */ + public void verifyTileIsPresent(String title, String subtitle) { + ArrayList searchResults = + new ArrayList<>(mLauncher.waitForObjectsInContainer( + mLauncher.waitForSystemLauncherObject(SEARCH_CONTAINER_RES_ID), + By.clazz(TextView.class))); + boolean foundTitle = false; + boolean foundSubtitle = false; + for (UiObject2 uiObject: searchResults) { + String currentString = uiObject.getText(); + if (TextUtils.equals(currentString, title)) { + foundTitle = true; + } else if (TextUtils.equals(currentString, subtitle)) { + foundSubtitle = true; + } + } + if (!foundTitle) { + mLauncher.fail("Tile not found for title: " + title); + } + if (!foundSubtitle) { + mLauncher.fail("Tile not found for subtitle: " + subtitle); + } + } }