1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-18 12:06:08 +00:00

workloads/youtube: Update Youtube workload

The previous known working version of the youtube apk appears
to have stopped working. Update to support the new format.
This commit is contained in:
Marc Bonnici 2020-11-10 20:23:47 +00:00 committed by setrofim
parent 5cfe452a35
commit 18439e3b31
3 changed files with 17 additions and 11 deletions

View File

@ -53,7 +53,7 @@ class Youtube(ApkUiautoWorkload):
5. Scroll down to the end of related videos and comments under the info card, and then
back up to the start. A maximum of 5 swipe actions is performed in either direction.
Known working APK version: 12.21.57
Known working APK version: 15.45.32
'''
package_names = ['com.google.android.youtube']

View File

@ -151,6 +151,14 @@ public class UiAutomation extends BaseUiAutomation {
}
}
private void playFirstVideo() throws Exception {
UiObject resultsList =
mDevice.findObject(new UiSelector().resourceId(packageID + "results"));
UiObject firstVideo =
resultsList.getFromParent(new UiSelector().clickable(true));
firstVideo.clickAndWaitForNewWindow();
}
public void testPlayVideo(String source, String searchTerm) throws Exception {
String testTag = "play";
ActionLogger logger = new ActionLogger(testTag + "_" + source, parameters);
@ -162,16 +170,13 @@ public class UiAutomation extends BaseUiAutomation {
mDevice.pressEnter();
// If a video exists whose title contains the exact search term, then play it
// Otherwise click the first video in the search results
UiObject thumbnail =
mDevice.findObject(new UiSelector().resourceId(packageID + "thumbnail"));
UiObject matchedVideo =
thumbnail.getFromParent(new UiSelector().textContains(searchTerm));
UiObject matchedVideo = mDevice.findObject(new UiSelector().descriptionContains(searchTerm));
logger.start();
if (matchedVideo.exists()) {
matchedVideo.clickAndWaitForNewWindow();
} else {
thumbnail.clickAndWaitForNewWindow();
playFirstVideo();
}
logger.stop();
@ -180,14 +185,15 @@ public class UiAutomation extends BaseUiAutomation {
clickUiObject(BY_TEXT, "My Videos", true);
logger.start();
clickUiObject(BY_ID, packageID + "thumbnail", true);
playFirstVideo();
logger.stop();
} else if (SOURCE_TRENDING.equalsIgnoreCase(source)) {
clickUiObject(BY_DESC, "Trending");
clickUiObject(BY_DESC, "Explore", true);
clickUiObject(BY_DESC, "Trending", true);
logger.start();
clickUiObject(BY_ID, packageID + "thumbnail", true);
playFirstVideo();
logger.stop();
} else { // homepage videos
@ -198,7 +204,7 @@ public class UiAutomation extends BaseUiAutomation {
}
logger.start();
clickUiObject(BY_ID, packageID + "thumbnail", true);
playFirstVideo();
logger.stop();
}