1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-01-19 04:21:17 +00:00

Skype: implement ApplaunchInterface

Adapts skype workload to support applaunch workload by implementing
the required methods of the interface.

Tested on Huawei Mate8 and Samsung S7.
This commit is contained in:
jummp01 2017-02-03 14:33:32 +00:00
parent ae0c9fa60b
commit cd05c36250
2 changed files with 61 additions and 16 deletions

View File

@ -24,6 +24,8 @@ import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.core.UiWatcher;
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
import com.arm.wlauto.uiauto.ApplaunchInterface;
import com.arm.wlauto.uiauto.UiAutoUtils;
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_ID;
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_TEXT;
@ -31,39 +33,26 @@ import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_DESC;
import java.util.concurrent.TimeUnit;
public class UiAutomation extends UxPerfUiAutomation {
public Bundle parameters;
public String packageName;
public String packageID;
public class UiAutomation extends UxPerfUiAutomation implements ApplaunchInterface {
public static final String ACTION_VOICE = "voice";
public static final String ACTION_VIDEO = "video";
public void runUiAutomation() throws Exception {
// Override superclass value
this.uiAutoTimeout = TimeUnit.SECONDS.toMillis(10);
parameters = getParams();
packageName = parameters.getString("package");
packageID = packageName + ":id/";
String loginName = parameters.getString("my_id");
String loginPass = parameters.getString("my_pwd");
String contactName = parameters.getString("name").replace("0space0", " ");
int callDuration = Integer.parseInt(parameters.getString("duration"));
String callType = parameters.getString("action");
String resultsFile = parameters.getString("results_file");
setScreenOrientation(ScreenOrientation.NATURAL);
runApplicationInitialization();
UiWatcher infoPopUpWatcher = createInfoPopUpWatcher();
registerWatcher("infoPopUpWatcher", infoPopUpWatcher);
runWatchers();
// Run tests
handleLoginScreen(loginName, loginPass);
dismissUpdatePopupIfPresent();
searchForContact(contactName);
if (ACTION_VOICE.equalsIgnoreCase(callType)) {
@ -75,6 +64,44 @@ public class UiAutomation extends UxPerfUiAutomation {
removeWatcher("infoPopUpWatcher");
unsetScreenOrientation();
}
// Get application parameters and clear the initial run dialogues of the application launch.
public void runApplicationInitialization() throws Exception {
getPackageParameters();
String loginName = parameters.getString("my_id");
String loginPass = parameters.getString("my_pwd");
UiWatcher infoPopUpWatcher = createInfoPopUpWatcher();
registerWatcher("infoPopUpWatcher", infoPopUpWatcher);
UiWatcher nextPopUpWatcher = createNextPopUpWatcher();
registerWatcher("nextPopUpWatcher", nextPopUpWatcher);
runWatchers();
// Run tests
handleLoginScreen(loginName, loginPass);
dismissUpdatePopupIfPresent();
}
// Sets the UiObject that marks the end of the application launch.
public UiObject getLaunchEndObject() {
UiObject launchEndObject = new UiObject(new UiSelector()
.resourceId(packageID + "menu_search"));
return launchEndObject;
}
// Returns the launch command for the application.
public String getLaunchCommand() {
String launch_command;
String actionName = "android.intent.action.VIEW";
String dataURI = "skype:dummy?dummy";
launch_command = String.format("am start -a %s -d %s", actionName, dataURI);
return launch_command;
}
// Pass the workload parameters, used for applaunch
public void setWorkloadParameters(Bundle workload_parameters) {
parameters = workload_parameters;
}
public void handleLoginScreen(String username, String password) throws Exception {
UiObject useridField =
@ -172,6 +199,24 @@ public class UiAutomation extends UxPerfUiAutomation {
};
return infoPopUpWatcher;
}
// Creates a watcher for when a pop up dialog appears with a next button on subsequent launch.
private UiWatcher createNextPopUpWatcher() throws Exception {
UiWatcher nextPopUpWatcher = new UiWatcher() {
@Override
public boolean checkForCondition() {
UiObject nextButton =
new UiObject(new UiSelector().resourceId(packageID + "next_button"));
if (nextButton.exists()) {
pressBack();
return nextButton.waitUntilGone(TimeUnit.SECONDS.toMillis(100));
}
return false;
}
};
return nextPopUpWatcher;
}
private void makeCall(int duration, boolean video) throws Exception {
String testTag = video ? "video" : "voice";