[PS] Add TAPL test for tile injection.

Bug: 330892261
Test: tapl
Flag: aconfig com.google.android.apps.nexuslauncher.enable_inject_private_space_tile nextfood

Change-Id: I4cfaefa26a81a1026d62d4206d90881f323bffd3
This commit is contained in:
Holly Sun
2024-04-29 20:05:12 -07:00
parent 05f201e8ac
commit 897791a9e7

View File

@@ -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<UiObject2> 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);
}
}
}