1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-14 06:38:36 +00:00

Merge 1092ef07fdafd604f308bb8e6b6253da40616eaf into 40d281b336979d5de76791889e828a70d08565fa

This commit is contained in:
jumana-arm 2016-11-24 16:28:45 +00:00 committed by GitHub
commit 390ffb5549
15 changed files with 225 additions and 2 deletions

Binary file not shown.

View File

@ -635,6 +635,10 @@ class AndroidUxPerfWorkload(AndroidUiAutoBenchmark):
super(AndroidUxPerfWorkload, self).validate()
self.uiauto_params['package'] = self.package
self.uiauto_params['markers_enabled'] = self.markers_enabled
if not self.activity:
self.uiauto_params['launch_activity'] = "None"
else:
self.uiauto_params['launch_activity'] = self.activity
def setup(self, context):
super(AndroidUxPerfWorkload, self).setup(context)

View File

@ -99,6 +99,88 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
}
}
}
/*
* AppLaunch class implements methods that facilitates launching applications from the uiautomator.
* ActionLogger class is instantiated within the class for measuring applaunch time.
* launch_main(): starts the application launch.
* launch_end(UiObject,int): marks the end of application launch, to measure the correct applaunch end time.
* @param Uiobject: is a workload specific object to search in the screen that potentially marks the beginning of user interaction.
* @param int: speficies the number of seconds to wait for the object to appear on screen, throws Uiobject not found exception.
*/
public class AppLaunch {
private String packageName;
private String activityName;
public String testTag = "applaunch";
public Bundle parameters;
public ActionLogger logger;
public AppLaunch(String packageName,
String activityName,
Bundle parameters) {
this.packageName = packageName;
this.activityName = activityName;
this.parameters = parameters;
this.logger = new ActionLogger(testTag, parameters);
}
//Called by launch_main() to check if app launch is successful
public void launch_validate(Process launch_p) throws Exception {
BufferedReader reader = new BufferedReader(new InputStreamReader(launch_p.getInputStream()));
String line = null;
while ((line = reader.readLine()) != null) {
if (line.contains("Error:")) {
throw new Exception("Application could not be launched");
}
}
}
//Marks the end of applaunch of the workload.
public void launch_end(UiObject launch_end_resource, int launch_timeout) throws Exception{
waitObject(launch_end_resource, launch_timeout);
logger.stop();
}
//Launches the application.
public void launch_main() throws Exception{
Process launch_p;
Process stop_app;
stop_app = Runtime.getRuntime().exec(String.format("am force-stop %s",
packageName));
logger.start();
if(activityName.equals("None")) {
launch_p = Runtime.getRuntime().exec(String.format("am start -W %s",
packageName));
Log.d("Launched without activity", activityName);
}
else {
launch_p = Runtime.getRuntime().exec(String.format("am start -W -n %s/%s",
packageName, activityName));
Log.d("Launched with activity", activityName);
}
launch_validate(launch_p);
stop_app.destroy();
launch_p.destroy();
}
//Launches the Skype application
public void launch_main(String actionName, String dataURI) throws Exception{
Process launch_p;
Process stop_app;
sleep(2);
stop_app = Runtime.getRuntime().exec(String.format("am force-stop %s",
packageName));
logger.start();
stop_app.waitFor();
launch_p = Runtime.getRuntime().exec(String.format("am start -W -a %s -d %s",
actionName, dataURI));
launch_p.waitFor();
launch_validate(launch_p);
stop_app.destroy();
launch_p.destroy();
}
}
public void sleep(int second) {
super.sleep(second * 1000);

View File

@ -39,6 +39,8 @@ public class UiAutomation extends UxPerfUiAutomation {
protected Bundle parameters;
protected String packageName;
protected String packageID;
public String activityName;
public Boolean applaunch_enabled;
private long networkTimeout = TimeUnit.SECONDS.toMillis(20);
private long searchTimeout = TimeUnit.SECONDS.toMillis(20);
@ -46,15 +48,28 @@ public class UiAutomation extends UxPerfUiAutomation {
public void runUiAutomation() throws Exception {
parameters = getParams();
packageName = parameters.getString("package");
activityName = parameters.getString("launch_activity");
packageID = packageName + ":id/";
applaunch_enabled = Boolean.parseBoolean(parameters.getString("markers_enabled"));
String filename = parameters.getString("filename").replace("0space0", " ");
String[] searchStrings =
parameters.getString("search_string_list").replace("0space0", " ").split("0newline0");
//Applaunch object for launching an application and measuring the time taken
AppLaunch applaunch = new AppLaunch(packageName, activityName, parameters);
//Widget on the screen that marks the application ready for user interaction
UiObject userBeginObject =
new UiObject(new UiSelector().textContains("RECENT")
.className("android.widget.TextView"));
setScreenOrientation(ScreenOrientation.NATURAL);
dismissWelcomeView();
if(applaunch_enabled) {
applaunch.launch_main();//launch the application
}
if(applaunch_enabled) {
applaunch.launch_end(userBeginObject,5);//mark the end of launch
}
openFile(filename);
gesturesTest();
searchPdfTest(searchStrings);

View File

@ -23,6 +23,7 @@ import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiWatcher;
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
@ -41,18 +42,41 @@ public class UiAutomation extends UxPerfUiAutomation {
public Bundle parameters;
public String packageName;
public String packageID;
public String activityName;
public Boolean applaunch_enabled;
private long viewTimeout = TimeUnit.SECONDS.toMillis(10);
public void runUiAutomation() throws Exception {
parameters = getParams();
packageName = parameters.getString("package");
activityName = parameters.getString("launch_activity");
packageID = packageName + ":id/";
applaunch_enabled = Boolean.parseBoolean(parameters.getString("markers_enabled"));
//Applaunch object for launching an application and measuring the time taken
AppLaunch applaunch = new AppLaunch(packageName, activityName, parameters);
//Widget on the screen that marks the application ready for user interaction
UiObject userBeginObject =
new UiObject(new UiSelector().textContains("Photos")
.className("android.widget.TextView"));
//Watcher that takes care of backup popup during warm start
UiWatcher backupPopUpWatcher = createBackupPopUpWatcher();
registerWatcher("backupPopUpWatcher", backupPopUpWatcher);
runWatchers();
sleep(5); // Pause while splash screen loads
setScreenOrientation(ScreenOrientation.NATURAL);
dismissWelcomeView();
closePromotionPopUp();
if(applaunch_enabled) {
applaunch.launch_main();//launch the application
}
if(applaunch_enabled) {
applaunch.launch_end(userBeginObject,5);//mark the end of launch
}
selectWorkingGallery("wa-1");
gesturesTest();
@ -435,4 +459,26 @@ public class UiAutomation extends UxPerfUiAutomation {
break;
}
}
// Creates a watcher for when a pop up dialog appears with a signin/close button.
private UiWatcher createBackupPopUpWatcher() throws Exception {
UiWatcher backupPopUpWatcher = new UiWatcher() {
@Override
public boolean checkForCondition() {
UiObject closeButton =
new UiObject(new UiSelector().resourceId(packageID + "promo_close_button"));
if (closeButton.exists()) {
try {
closeButton.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
return closeButton.waitUntilGone(TimeUnit.SECONDS.toMillis(10));
}
return false;
}
};
return backupPopUpWatcher;
}
}

View File

@ -43,6 +43,8 @@ public class UiAutomation extends UxPerfUiAutomation {
protected Bundle parameters;
protected String packageName;
protected String packageID;
public String activityName;
public Boolean applaunch_enabled;
private int viewTimeoutSecs = 10;
private long viewTimeout = TimeUnit.SECONDS.toMillis(viewTimeoutSecs);
@ -53,7 +55,9 @@ public class UiAutomation extends UxPerfUiAutomation {
parameters = getParams();
packageName = parameters.getString("package");
activityName = parameters.getString("launch_activity");
packageID = packageName + ":id/";
applaunch_enabled = Boolean.parseBoolean(parameters.getString("markers_enabled"));
String searchBookTitle = parameters.getString("search_book_title").replace("0space0", " ");
String libraryBookTitle = parameters.getString("library_book_title").replace("0space0", " ");
@ -62,6 +66,12 @@ public class UiAutomation extends UxPerfUiAutomation {
String noteText = "This is a test note";
String account = parameters.getString("account");
//Applaunch object for launching an application and measuring the time taken
AppLaunch applaunch = new AppLaunch(packageName, activityName, parameters);
//Widget on the screen that marks the application ready for user interaction
UiObject userBeginObject =
new UiObject(new UiSelector().resourceId(packageID + "menu_search"));
setScreenOrientation(ScreenOrientation.NATURAL);
chooseAccount(account);
@ -69,6 +79,13 @@ public class UiAutomation extends UxPerfUiAutomation {
dismissSendBooksAsGiftsDialog();
dismissSync();
if(applaunch_enabled) {
applaunch.launch_main();//launch the application
}
if(applaunch_enabled) {
applaunch.launch_end(userBeginObject,5);//mark the end of launch
}
searchForBook(searchBookTitle);
addToLibrary();
openMyLibrary();

View File

@ -36,6 +36,10 @@ public class UiAutomation extends UxPerfUiAutomation {
public Bundle parameters;
public String packageName;
public String packageID;
public String activityName;
public String actionName = "android.intent.action.VIEW"; //required for launching skype
public String dataURI = "skype:dummy?dummy"; // required for launching skype
public Boolean applaunch_enabled;
public static final String ACTION_VOICE = "voice";
public static final String ACTION_VIDEO = "video";
@ -46,7 +50,9 @@ public class UiAutomation extends UxPerfUiAutomation {
parameters = getParams();
packageName = parameters.getString("package");
activityName = parameters.getString("launch_activity");
packageID = packageName + ":id/";
applaunch_enabled = Boolean.parseBoolean(parameters.getString("markers_enabled"));
String loginName = parameters.getString("my_id");
String loginPass = parameters.getString("my_pwd");
@ -54,6 +60,13 @@ public class UiAutomation extends UxPerfUiAutomation {
int callDuration = Integer.parseInt(parameters.getString("duration"));
String callType = parameters.getString("action");
String resultsFile = parameters.getString("results_file");
//Applaunch object for launching an application and measuring the time taken
AppLaunch applaunch = new AppLaunch(packageName, activityName, parameters);
//Widget on the screen that marks the application ready for user interaction
UiObject userBeginObject =
new UiObject(new UiSelector().resourceId(packageID + "menu_search"));
setScreenOrientation(ScreenOrientation.NATURAL);
@ -64,6 +77,12 @@ public class UiAutomation extends UxPerfUiAutomation {
// Run tests
handleLoginScreen(loginName, loginPass);
dismissUpdatePopupIfPresent();
if(applaunch_enabled) {
applaunch.launch_main(actionName,dataURI);//launch the application
}
if(applaunch_enabled) {
applaunch.launch_end(userBeginObject,5);//mark the end of launch
}
searchForContact(contactName);
if (ACTION_VOICE.equalsIgnoreCase(callType)) {
@ -165,6 +184,29 @@ public class UiAutomation extends UxPerfUiAutomation {
return infoPopUpWatcher;
}
// Creates a watcher for when a pop up dialog appears with a continue button.
private UiWatcher createUpdatePopUpWatcher() throws Exception {
UiWatcher updatePopUpWatcher = new UiWatcher() {
@Override
public boolean checkForCondition() {
UiObject continueButton =
new UiObject(new UiSelector().resourceId(packageID + "button2"));
if (continueButton.exists()) {
try {
continueButton.click();
} catch (UiObjectNotFoundException e) {
e.printStackTrace();
}
return continueButton.waitUntilGone(TimeUnit.SECONDS.toMillis(10));
}
return false;
}
};
return updatePopUpWatcher;
}
private void voiceCallTest(int duration) throws Exception {
String testTag = "call_voice";
ActionLogger logger = new ActionLogger(testTag, parameters);

View File

@ -17,6 +17,7 @@ package com.arm.wlauto.uiauto.youtube;
import android.os.Bundle;
import android.os.SystemClock;
import android.util.Log;
// Import the uiautomator libraries
import com.android.uiautomator.core.UiObject;
@ -34,6 +35,8 @@ public class UiAutomation extends UxPerfUiAutomation {
public Bundle parameters;
public String packageName;
public String packageID;
public String activityName;
public Boolean applaunch_enabled;
public static final String SOURCE_MY_VIDEOS = "my_videos";
public static final String SOURCE_SEARCH = "search";
@ -46,7 +49,9 @@ public class UiAutomation extends UxPerfUiAutomation {
public void runUiAutomation() throws Exception {
parameters = getParams();
packageName = parameters.getString("package");
activityName = parameters.getString("launch_activity");
packageID = packageName + ":id/";
applaunch_enabled = Boolean.parseBoolean(parameters.getString("markers_enabled"));
String videoSource = parameters.getString("video_source");
String searchTerm = parameters.getString("search_term");
@ -54,10 +59,22 @@ public class UiAutomation extends UxPerfUiAutomation {
searchTerm = searchTerm.replace("0space0", " ");
}
//Applaunch object for launching an application and measuring the time taken
AppLaunch applaunch = new AppLaunch(packageName, activityName, parameters);
//Widget on the screen that marks the application ready for user interaction
UiObject userBeginObject =
new UiObject(new UiSelector().textContains("Home")
.className("android.widget.TextView"));
setScreenOrientation(ScreenOrientation.NATURAL);
clearFirstRunDialogues();
disableAutoplay();
if(applaunch_enabled) {
applaunch.launch_main();//launch the application
}
if(applaunch_enabled) {
applaunch.launch_end(userBeginObject,5);//mark the end of launch
}
testPlayVideo(videoSource, searchTerm);
dismissAdvert();
checkPlayerError();