mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-04-15 23:30:47 +01:00
Adds AppLaunch class in Uiauto Base class
A new class AppLaunch added that facilitates launching applications from the uiautomator. Moreover, applaunch measurement markers are placed to measure the cold-start time of applications. 1- Turns off WA-applaunch if uxperf markers enabled Launching application from WA is disabled if uxperf markers are enabled. The new applaunch class will be used to launch application from the uiautomator so that application launch time can be measured. 2- Application activity name is passed as a parameter to the uiautomator as it is required for launching certain applications. 3- Googlephotos: Adds the applaunch call in the workload It looks for the text, Photos, on the screen to mark the end of the launch. 4- Adobereader: Adds the applaunch call in the workload It looks for the text,RECENT,on the screen in the opening page after welcomepages for launch end. 5- Youtube: Adds the Applaunch call in the workload It looks for the text,Home, for marking applaunch end time. 6- Googleplaybooks: Adds the applaunch call in the workload It looks for the search icon for applaunch end. 6- Adds applaunch method for skype Skype launches with an action name and data_uri unlike other applications. For supporting this an overridden launch_main() method is introduced in the AppLaunch class. 7- Skype: Adds the applaunch call in the workload The end marker is set to search for the search for contact icon. 8- Fixes sending empty activity as parameter Activity name being sent as parameter throws error as android does not support sending empty string. Fixed by sending the string None if the string is empty. 9- Tested for all the above workloads on s7. All workloads ran with the new base class and jar files are added
This commit is contained in:
parent
40d281b336
commit
b323d98e51
Binary file not shown.
BIN
wlauto/common/android/BaseUiAutomation$AppLaunch.class
Normal file
BIN
wlauto/common/android/BaseUiAutomation$AppLaunch.class
Normal file
Binary file not shown.
Binary file not shown.
@ -630,11 +630,18 @@ class AndroidUxPerfWorkload(AndroidUiAutoBenchmark):
|
||||
super(AndroidUxPerfWorkload, self).__init__(device, **kwargs)
|
||||
# Turn class attribute into instance attribute
|
||||
self.deployable_assets = list(self.deployable_assets)
|
||||
# Turn off app launch from wa if markers are enabled for uxperf
|
||||
if self.markers_enabled:
|
||||
self.launch_main = False
|
||||
|
||||
def validate(self):
|
||||
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)
|
||||
|
@ -99,6 +99,77 @@ 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;
|
||||
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);
|
||||
launch_p.destroy();
|
||||
}
|
||||
//Launches the Skype application
|
||||
public void launch_main(String actionName, String dataURI) throws Exception{
|
||||
Process launch_p;
|
||||
logger.start();
|
||||
launch_p = Runtime.getRuntime().exec(String.format("am start -W -a %s -d %s",
|
||||
actionName, dataURI));
|
||||
|
||||
launch_validate(launch_p);
|
||||
launch_p.destroy();
|
||||
}
|
||||
}
|
||||
|
||||
public void sleep(int second) {
|
||||
super.sleep(second * 1000);
|
||||
|
Binary file not shown.
@ -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"));
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_main();//launch the application
|
||||
}
|
||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||
|
||||
dismissWelcomeView();
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_end(userBeginObject,5);//mark the end of launch
|
||||
}
|
||||
openFile(filename);
|
||||
gesturesTest();
|
||||
searchPdfTest(searchStrings);
|
||||
|
Binary file not shown.
@ -41,19 +41,37 @@ 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"));
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_main();//launch the application
|
||||
}
|
||||
|
||||
|
||||
sleep(5); // Pause while splash screen loads
|
||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||
dismissWelcomeView();
|
||||
closePromotionPopUp();
|
||||
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_end(userBeginObject,5);//mark the end of launch
|
||||
}
|
||||
|
||||
selectWorkingGallery("wa-1");
|
||||
gesturesTest();
|
||||
navigateUp();
|
||||
|
Binary file not shown.
@ -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,15 @@ 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"));
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_main();//launch the application
|
||||
}
|
||||
|
||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||
|
||||
chooseAccount(account);
|
||||
@ -69,6 +82,10 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
dismissSendBooksAsGiftsDialog();
|
||||
dismissSync();
|
||||
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_end(userBeginObject,5);//mark the end of launch
|
||||
}
|
||||
|
||||
searchForBook(searchBookTitle);
|
||||
addToLibrary();
|
||||
openMyLibrary();
|
||||
|
Binary file not shown.
@ -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");
|
||||
@ -55,6 +61,16 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
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"));
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_main(actionName,dataURI);//launch the application
|
||||
}
|
||||
|
||||
|
||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||
|
||||
UiWatcher infoPopUpWatcher = createInfoPopUpWatcher();
|
||||
@ -64,6 +80,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
// Run tests
|
||||
handleLoginScreen(loginName, loginPass);
|
||||
dismissUpdatePopupIfPresent();
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_end(userBeginObject,5);//mark the end of launch
|
||||
}
|
||||
searchForContact(contactName);
|
||||
|
||||
if (ACTION_VOICE.equalsIgnoreCase(callType)) {
|
||||
|
Binary file not shown.
@ -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"));
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_main();//launch the application
|
||||
}
|
||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||
|
||||
clearFirstRunDialogues();
|
||||
disableAutoplay();
|
||||
if(applaunch_enabled) {
|
||||
applaunch.launch_end(userBeginObject,5);//mark the end of launch
|
||||
}
|
||||
testPlayVideo(videoSource, searchTerm);
|
||||
dismissAdvert();
|
||||
checkPlayerError();
|
||||
|
Loading…
x
Reference in New Issue
Block a user