mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-01-31 02:01:16 +00:00
workloads/googleplaybooks: Update to handle updated IDs
Resourceid and classes have been modified so update the workload to handle these cases. Additionally on some devices regex matches appear to fail so workaround to match separately.
This commit is contained in:
parent
62c4f3837c
commit
91b791665a
Binary file not shown.
@ -98,7 +98,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
removeNote();
|
removeNote();
|
||||||
searchForWord(searchWord);
|
searchForWord(searchWord);
|
||||||
switchPageStyles();
|
switchPageStyles();
|
||||||
aboutBook();
|
aboutBook(libraryBookTitle);
|
||||||
pressBack();
|
pressBack();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -232,21 +232,28 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
UiObject resultList =
|
UiObject resultList =
|
||||||
mDevice.findObject(new UiSelector().resourceId("com.android.vending:id/search_results_list"));
|
mDevice.findObject(new UiSelector().resourceId("com.android.vending:id/search_results_list"));
|
||||||
if (!resultList.waitForExists(viewTimeout)) {
|
if (!resultList.waitForExists(viewTimeout)) {
|
||||||
throw new UiObjectNotFoundException("Could not find \"search results list view\".");
|
resultList =
|
||||||
|
mDevice.findObject(new UiSelector().className("android.support.v7.widget.RecyclerView")
|
||||||
|
.scrollable(true));
|
||||||
|
if (!resultList.waitForExists(viewTimeout)) {
|
||||||
|
throw new UiObjectNotFoundException("Could not find search results list.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create a selector so that we can search for siblings of the desired
|
// Create a selector so that we can search for siblings of the desired
|
||||||
// book that contains a "free" or "purchased" book identifier
|
// book that contains a "free" or "purchased" book identifier
|
||||||
UiObject label =
|
// For some reason regex matching seem to be failing so explicitally check for both.
|
||||||
mDevice.findObject(new UiSelector().description(String.format("Book: " + bookTitle))
|
UiObject labelPurchased =
|
||||||
.className("android.widget.TextView"))
|
mDevice.findObject(new UiSelector().descriptionContains(String.format("Book: %s", bookTitle))
|
||||||
.resourceId("com.android.vending:id/li_label")
|
.descriptionContains("Purchased"));
|
||||||
.descriptionMatches("^(Purchased|Free)$"));
|
UiObject labelFree =
|
||||||
|
mDevice.findObject(new UiSelector().descriptionContains(String.format("Book: %s", bookTitle))
|
||||||
|
.descriptionContains("Free"));
|
||||||
|
|
||||||
final int maxSearchTime = 30;
|
final int maxSearchTime = 30;
|
||||||
int searchTime = maxSearchTime;
|
int searchTime = maxSearchTime;
|
||||||
|
|
||||||
while (!label.exists()) {
|
while (!(labelPurchased.exists() || labelFree.exists())) {
|
||||||
if (searchTime > 0) {
|
if (searchTime > 0) {
|
||||||
uiDeviceSwipeDown(100);
|
uiDeviceSwipeDown(100);
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -260,7 +267,12 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
|
|
||||||
// Click on either the first "free" or "purchased" book found that
|
// Click on either the first "free" or "purchased" book found that
|
||||||
// matches the book title
|
// matches the book title
|
||||||
label.click();
|
if (labelPurchased.exists()) {
|
||||||
|
labelPurchased.click();
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
labelFree.click();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void addToLibrary() throws Exception {
|
private void addToLibrary() throws Exception {
|
||||||
@ -583,7 +595,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
waitForPage();
|
waitForPage();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void aboutBook() throws Exception {
|
private void aboutBook(final String bookTitle) throws Exception {
|
||||||
String testTag = "open_about";
|
String testTag = "open_about";
|
||||||
ActionLogger logger = new ActionLogger(testTag, parameters);
|
ActionLogger logger = new ActionLogger(testTag, parameters);
|
||||||
|
|
||||||
@ -598,7 +610,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
bookInfo.clickAndWaitForNewWindow(uiAutoTimeout);
|
bookInfo.clickAndWaitForNewWindow(uiAutoTimeout);
|
||||||
|
|
||||||
UiObject detailsPanel =
|
UiObject detailsPanel =
|
||||||
mDevice.findObject(new UiSelector().resourceId("com.android.vending:id/item_details_panel"));
|
mDevice.findObject(new UiSelector().textContains(bookTitle));
|
||||||
waitObject(detailsPanel, viewTimeoutSecs);
|
waitObject(detailsPanel, viewTimeoutSecs);
|
||||||
|
|
||||||
logger.stop();
|
logger.stop();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user