diff --git a/wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar b/wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar index 34ba170c..2f764bdc 100644 Binary files a/wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar and b/wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar differ diff --git a/wlauto/workloads/skype/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java b/wlauto/workloads/skype/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java index 5fa5a30c..1fc763f9 100755 --- a/wlauto/workloads/skype/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java +++ b/wlauto/workloads/skype/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java @@ -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";