mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-21 20:38:57 +00:00
Merge pull request #248 from jimboatarm/youtube-actionlogger-modified
Youtube: Changed actionlogger to measure different more relevant acti…
This commit is contained in:
commit
fe58245843
Binary file not shown.
69
wlauto/workloads/youtube/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java
Normal file → Executable file
69
wlauto/workloads/youtube/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java
Normal file → Executable file
@ -36,7 +36,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
public static final String CLASS_TEXT_VIEW = "android.widget.TextView";
|
public static final String CLASS_TEXT_VIEW = "android.widget.TextView";
|
||||||
|
|
||||||
public static final int WAIT_TIMEOUT_1SEC = 1000;
|
public static final int WAIT_TIMEOUT_1SEC = 1000;
|
||||||
public static final int WAIT_TIMEOUT_5SEC = 5000;
|
|
||||||
public static final int VIDEO_SLEEP_SECONDS = 3;
|
public static final int VIDEO_SLEEP_SECONDS = 3;
|
||||||
public static final int LIST_SWIPE_COUNT = 5;
|
public static final int LIST_SWIPE_COUNT = 5;
|
||||||
public static final String SOURCE_MY_VIDEOS = "my_videos";
|
public static final String SOURCE_MY_VIDEOS = "my_videos";
|
||||||
@ -47,12 +46,14 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
protected Bundle parameters;
|
protected Bundle parameters;
|
||||||
protected String packageName;
|
protected String packageName;
|
||||||
protected String packageID;
|
protected String packageID;
|
||||||
|
protected String videoSource;
|
||||||
protected String searchTerm;
|
protected String searchTerm;
|
||||||
|
|
||||||
public void runUiAutomation() throws Exception {
|
public void runUiAutomation() throws Exception {
|
||||||
parameters = getParams();
|
parameters = getParams();
|
||||||
packageName = parameters.getString("package");
|
packageName = parameters.getString("package");
|
||||||
packageID = packageName + ":id/";
|
packageID = packageName + ":id/";
|
||||||
|
videoSource = parameters.getString("video_source");
|
||||||
searchTerm = parameters.getString("search_term");
|
searchTerm = parameters.getString("search_term");
|
||||||
if (searchTerm != null) {
|
if (searchTerm != null) {
|
||||||
searchTerm = searchTerm.replaceAll("0space0", " ");
|
searchTerm = searchTerm.replaceAll("0space0", " ");
|
||||||
@ -61,7 +62,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||||
clearFirstRunDialogues();
|
clearFirstRunDialogues();
|
||||||
disableAutoplay();
|
disableAutoplay();
|
||||||
testPlayVideo(parameters.getString("video_source"), searchTerm);
|
testPlayVideo(videoSource, searchTerm);
|
||||||
unsetScreenOrientation();
|
unsetScreenOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -86,12 +87,8 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
|
|
||||||
public void disableAutoplay() throws Exception {
|
public void disableAutoplay() throws Exception {
|
||||||
clickUiObject(BY_DESC, "More options");
|
clickUiObject(BY_DESC, "More options");
|
||||||
startMeasurements("goto_settings");
|
|
||||||
clickUiObject(BY_TEXT, "Settings", true);
|
clickUiObject(BY_TEXT, "Settings", true);
|
||||||
endMeasurements("goto_settings");
|
|
||||||
startMeasurements("goto_settings_general");
|
|
||||||
clickUiObject(BY_TEXT, "General", true);
|
clickUiObject(BY_TEXT, "General", true);
|
||||||
endMeasurements("goto_settings_general");
|
|
||||||
|
|
||||||
// Don't fail fatally if autoplay toggle cannot be found
|
// Don't fail fatally if autoplay toggle cannot be found
|
||||||
UiObject autoplayToggle = new UiObject(new UiSelector().textContains("Autoplay"));
|
UiObject autoplayToggle = new UiObject(new UiSelector().textContains("Autoplay"));
|
||||||
@ -109,30 +106,13 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void testPlayVideo(String source, String searchTerm) throws Exception {
|
public void testPlayVideo(String source, String searchTerm) throws Exception {
|
||||||
if (SOURCE_MY_VIDEOS.equalsIgnoreCase(source)) {
|
if (SOURCE_SEARCH.equalsIgnoreCase(source)) {
|
||||||
startMeasurements("goto_account");
|
|
||||||
clickUiObject(BY_DESC, "Account");
|
|
||||||
endMeasurements("goto_account");
|
|
||||||
startMeasurements("goto_my_videos");
|
|
||||||
clickUiObject(BY_TEXT, "My Videos", true);
|
|
||||||
endMeasurements("goto_my_videos");
|
|
||||||
|
|
||||||
startMeasurements("play_from_my_videos");
|
|
||||||
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
|
||||||
endMeasurements("play_from_my_videos");
|
|
||||||
|
|
||||||
} else if (SOURCE_SEARCH.equalsIgnoreCase(source)) {
|
|
||||||
startMeasurements("goto_search");
|
|
||||||
clickUiObject(BY_DESC, "Search");
|
clickUiObject(BY_DESC, "Search");
|
||||||
endMeasurements("goto_search");
|
|
||||||
|
|
||||||
startMeasurements("search_video");
|
|
||||||
UiObject textField = getUiObjectByResourceId(packageID + "search_edit_text");
|
UiObject textField = getUiObjectByResourceId(packageID + "search_edit_text");
|
||||||
textField.setText(searchTerm);
|
textField.setText(searchTerm);
|
||||||
endMeasurements("search_video");
|
|
||||||
|
|
||||||
getUiDevice().pressEnter();
|
getUiDevice().pressEnter();
|
||||||
startMeasurements("play_from_search");
|
|
||||||
|
startMeasurements("play_search");
|
||||||
// If a video exists whose title contains the exact search term, then play it
|
// If a video exists whose title contains the exact search term, then play it
|
||||||
// Otherwise click the first video in the search results
|
// Otherwise click the first video in the search results
|
||||||
UiObject thumbnail = new UiObject(new UiSelector().resourceId(packageID + "thumbnail"));
|
UiObject thumbnail = new UiObject(new UiSelector().resourceId(packageID + "thumbnail"));
|
||||||
@ -142,25 +122,28 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
} else {
|
} else {
|
||||||
thumbnail.clickAndWaitForNewWindow();
|
thumbnail.clickAndWaitForNewWindow();
|
||||||
}
|
}
|
||||||
endMeasurements("play_from_search");
|
endMeasurements();
|
||||||
|
} else if (SOURCE_MY_VIDEOS.equalsIgnoreCase(source)) {
|
||||||
|
clickUiObject(BY_DESC, "Account");
|
||||||
|
clickUiObject(BY_TEXT, "My Videos", true);
|
||||||
|
|
||||||
} else if (SOURCE_TRENDING.equalsIgnoreCase(source)) {
|
startMeasurements("play_myvideos");
|
||||||
startMeasurements("goto_trending");
|
|
||||||
clickUiObject(BY_DESC, "Trending");
|
|
||||||
endMeasurements("goto_trending");
|
|
||||||
|
|
||||||
startMeasurements("play_from_trending");
|
|
||||||
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
||||||
endMeasurements("play_from_trending");
|
endMeasurements();
|
||||||
|
} else if (SOURCE_TRENDING.equalsIgnoreCase(source)) {
|
||||||
|
clickUiObject(BY_DESC, "Trending");
|
||||||
|
|
||||||
|
startMeasurements("play_trending");
|
||||||
|
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
||||||
|
endMeasurements();
|
||||||
} else { // homepage videos
|
} else { // homepage videos
|
||||||
UiScrollable list = new UiScrollable(new UiSelector().resourceId(packageID + "results"));
|
UiScrollable list = new UiScrollable(new UiSelector().resourceId(packageID + "results"));
|
||||||
if (list.exists()) {
|
if (list.exists()) {
|
||||||
list.scrollForward();
|
list.scrollForward();
|
||||||
}
|
}
|
||||||
startMeasurements("play_from_home");
|
startMeasurements("play_home");
|
||||||
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
clickUiObject(BY_ID, packageID + "thumbnail", true);
|
||||||
endMeasurements("play_from_home");
|
endMeasurements();
|
||||||
}
|
}
|
||||||
|
|
||||||
dismissAdvert();
|
dismissAdvert();
|
||||||
@ -174,7 +157,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
UiObject advert = new UiObject(new UiSelector().textContains("Visit advertiser"));
|
UiObject advert = new UiObject(new UiSelector().textContains("Visit advertiser"));
|
||||||
if (advert.exists()) {
|
if (advert.exists()) {
|
||||||
UiObject skip = new UiObject(new UiSelector().textContains("Skip ad"));
|
UiObject skip = new UiObject(new UiSelector().textContains("Skip ad"));
|
||||||
if (skip.waitForExists(WAIT_TIMEOUT_5SEC)) {
|
if (skip.waitForExists(WAIT_TIMEOUT_1SEC*5)) {
|
||||||
skip.click();
|
skip.click();
|
||||||
sleep(VIDEO_SLEEP_SECONDS);
|
sleep(VIDEO_SLEEP_SECONDS);
|
||||||
}
|
}
|
||||||
@ -195,9 +178,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
repeatClickUiObject(player, 2, 100);
|
repeatClickUiObject(player, 2, 100);
|
||||||
sleep(1); // pause the video momentarily
|
sleep(1); // pause the video momentarily
|
||||||
player.click();
|
player.click();
|
||||||
startMeasurements("player_video_windowed");
|
|
||||||
sleep(VIDEO_SLEEP_SECONDS);
|
sleep(VIDEO_SLEEP_SECONDS);
|
||||||
endMeasurements("player_video_windowed");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void checkVideoInfo() throws Exception {
|
public void checkVideoInfo() throws Exception {
|
||||||
@ -215,13 +196,13 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
// ListView of related videos and (maybe) comments
|
// ListView of related videos and (maybe) comments
|
||||||
UiScrollable list = new UiScrollable(new UiSelector().resourceId(packageID + "watch_list"));
|
UiScrollable list = new UiScrollable(new UiSelector().resourceId(packageID + "watch_list"));
|
||||||
if (list.isScrollable()) {
|
if (list.isScrollable()) {
|
||||||
startMeasurements("watch_list_fling_down");
|
startMeasurements("scroll_down");
|
||||||
list.flingToEnd(LIST_SWIPE_COUNT);
|
list.flingToEnd(LIST_SWIPE_COUNT);
|
||||||
endMeasurements("watch_list_fling_down");
|
endMeasurements();
|
||||||
|
|
||||||
startMeasurements("watch_list_fling_up");
|
startMeasurements("scroll_up");
|
||||||
list.flingToBeginning(LIST_SWIPE_COUNT);
|
list.flingToBeginning(LIST_SWIPE_COUNT);
|
||||||
endMeasurements("watch_list_fling_up");
|
endMeasurements();
|
||||||
}
|
}
|
||||||
// After flinging, give the window enough time to settle down before
|
// After flinging, give the window enough time to settle down before
|
||||||
// the next step, or else UiAutomator fails to find views in time
|
// the next step, or else UiAutomator fails to find views in time
|
||||||
@ -233,7 +214,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
logger.start();
|
logger.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void endMeasurements(String testTag) throws Exception {
|
protected void endMeasurements() throws Exception {
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user