1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-22 04:49:00 +00:00

Skype CodeTidy to conform with the other workloads

Dont double click if the confirm icon appears
This commit is contained in:
Michael McGeagh 2016-09-28 14:02:39 +01:00
parent 77d724efa3
commit 4e94ff9ed7
3 changed files with 49 additions and 52 deletions

View File

@ -13,13 +13,22 @@
# limitations under the License. # limitations under the License.
# #
import time
from wlauto import AndroidUxPerfWorkload, Parameter from wlauto import AndroidUxPerfWorkload, Parameter
class Skype(AndroidUxPerfWorkload): class Skype(AndroidUxPerfWorkload):
name = 'skype' name = 'skype'
package = 'com.skype.raider'
min_apk_version = '7.01.0.669'
activity = '' # Skype has no default 'main' activity
view = [package + '/com.skype.android.app.calling.CallActivity',
package + '/com.skype.android.app.calling.PreCallActivity',
package + '/com.skype.android.app.chat.ChatActivity',
package + '/com.skype.android.app.main.HubActivity',
package + '/com.skype.android.app.main.SplashActivity',
package + '/com.skype.android.app.signin.SignInActivity',
package + '/com.skype.android.app.signin.UnifiedLandingPageActivity']
description = ''' description = '''
A workload to perform standard productivity tasks within Skype. The A workload to perform standard productivity tasks within Skype. The
workload logs in to the Skype application, selects a recipient from the workload logs in to the Skype application, selects a recipient from the
@ -50,17 +59,7 @@ class Skype(AndroidUxPerfWorkload):
please search online for specific instructions). please search online for specific instructions).
https://support.skype.com/en/faq/FA3751/can-i-automatically-answer-all-my-calls-with-video-in-skype-for-windows-desktop https://support.skype.com/en/faq/FA3751/can-i-automatically-answer-all-my-calls-with-video-in-skype-for-windows-desktop
''' '''
package = 'com.skype.raider'
min_apk_version = '7.01.0.669'
view = [package + '/com.skype.android.app.calling.CallActivity',
package + '/com.skype.android.app.calling.PreCallActivity',
package + '/com.skype.android.app.chat.ChatActivity',
package + '/com.skype.android.app.main.HubActivity',
package + '/com.skype.android.app.main.SplashActivity',
package + '/com.skype.android.app.signin.SignInActivity',
package + '/com.skype.android.app.signin.UnifiedLandingPageActivity']
activity = '' # Skype has no default 'main' activity
launch_main = False # overrides extended class launch_main = False # overrides extended class
parameters = [ parameters = [
@ -70,7 +69,7 @@ class Skype(AndroidUxPerfWorkload):
'''), '''),
Parameter('login_pass', kind=str, mandatory=True, Parameter('login_pass', kind=str, mandatory=True,
description='Password associated with the account to log into the device'), description='Password associated with the account to log into the device'),
Parameter('contact_name', kind=str, mandatory=True, default='Echo / Sound Test Service', Parameter('contact_name', kind=str, default='Echo / Sound Test Service',
description='This is the contact display name as it appears in the people list'), description='This is the contact display name as it appears in the people list'),
Parameter('duration', kind=int, default=10, Parameter('duration', kind=int, default=10,
description='This is the duration of the call in seconds'), description='This is the duration of the call in seconds'),

View File

@ -22,27 +22,32 @@ import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException; import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiSelector; import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.core.UiWatcher; import com.android.uiautomator.core.UiWatcher;
import com.arm.wlauto.uiauto.UxPerfUiAutomation; import com.arm.wlauto.uiauto.UxPerfUiAutomation;
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_ID;
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_TEXT;
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_DESC;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
public class UiAutomation extends UxPerfUiAutomation { public class UiAutomation extends UxPerfUiAutomation {
public static final String ACTION_VOICE = "voice";
public static final String ACTION_VIDEO = "video";
public Bundle parameters; public Bundle parameters;
public String packageName; public String packageName;
public String packageID; public String packageID;
public static final String ACTION_VOICE = "voice";
public static final String ACTION_VIDEO = "video";
public void runUiAutomation() throws Exception { public void runUiAutomation() throws Exception {
// Override superclass value // Override superclass value
this.uiAutoTimeout = TimeUnit.SECONDS.toMillis(10); this.uiAutoTimeout = TimeUnit.SECONDS.toMillis(10);
// Get Params
parameters = getParams(); parameters = getParams();
packageName = parameters.getString("package"); packageName = parameters.getString("package");
packageID = packageName + ":id/"; packageID = packageName + ":id/";
String loginName = parameters.getString("my_id"); String loginName = parameters.getString("my_id");
String loginPass = parameters.getString("my_pwd"); String loginPass = parameters.getString("my_pwd");
String contactName = parameters.getString("name").replace("0space0", " "); String contactName = parameters.getString("name").replace("0space0", " ");
@ -72,17 +77,17 @@ public class UiAutomation extends UxPerfUiAutomation {
} }
public void handleLoginScreen(String username, String password) throws Exception { public void handleLoginScreen(String username, String password) throws Exception {
String useridResoureId = packageID + "sign_in_userid"; UiObject useridField =
String nextButtonResourceId = packageID + "sign_in_next_btn"; new UiObject(new UiSelector().resourceId(packageID + "sign_in_userid"));
UiObject useridField = new UiObject(new UiSelector().resourceId(useridResoureId)); UiObject nextButton =
UiObject nextButton = new UiObject(new UiSelector().resourceId(nextButtonResourceId)); new UiObject(new UiSelector().resourceId(packageID + "sign_in_next_btn"));
useridField.setText(username); useridField.setText(username);
nextButton.clickAndWaitForNewWindow(); nextButton.clickAndWaitForNewWindow();
String passwordResoureId = packageID + "signin_password"; UiObject passwordField =
String signinButtonResourceId = packageID + "sign_in_btn"; new UiObject(new UiSelector().resourceId(packageID + "signin_password"));
UiObject passwordField = new UiObject(new UiSelector().resourceId(passwordResoureId)); UiObject signinButton =
UiObject signinButton = new UiObject(new UiSelector().resourceId(signinButtonResourceId)); new UiObject(new UiSelector().resourceId(packageID + "sign_in_btn"));
passwordField.setText(password); passwordField.setText(password);
signinButton.clickAndWaitForNewWindow(); signinButton.clickAndWaitForNewWindow();
} }
@ -90,55 +95,49 @@ public class UiAutomation extends UxPerfUiAutomation {
public void dismissUpdatePopupIfPresent() throws Exception { public void dismissUpdatePopupIfPresent() throws Exception {
UiObject updateNotice = UiObject updateNotice =
new UiObject(new UiSelector().resourceId(packageID + "update_notice_dont_show_again")); new UiObject(new UiSelector().resourceId(packageID + "update_notice_dont_show_again"));
//Detect if the update notice popup is present //Detect if the update notice popup is present
if (updateNotice.waitForExists(uiAutoTimeout)) { if (updateNotice.waitForExists(uiAutoTimeout)) {
//Stop the notice from reappearing //Stop the notice from reappearing
updateNotice.click(); updateNotice.click();
clickUiObject(BY_TEXT, "Continue", "android.widget.Button");
UiObject contiuneButton = getUiObjectByText("Continue", "android.widget.Button");
if (contiuneButton.exists()) {
contiuneButton.click();
}
} }
} }
public void searchForContact(String name) throws Exception { public void searchForContact(String name) throws Exception {
UiObject menuSearch = new UiObject(new UiSelector().resourceId(packageID + "menu_search"));
boolean sharingResource = false; boolean sharingResource = false;
UiObject menuSearch =
// If searching for a contact from Skype directly we need new UiObject(new UiSelector().resourceId(packageID + "menu_search"));
// to click the menu search button to display the contact search box.
if (menuSearch.waitForExists(uiAutoTimeout)) { if (menuSearch.waitForExists(uiAutoTimeout)) {
// If searching for a contact from Skype directly we need
// to click the menu search button to display the contact search box.
menuSearch.click(); menuSearch.click();
// If sharing a resource from another app the contact search box is shown
// by default.
} else { } else {
// If sharing a resource from another app the contact search box is shown
// by default.
sharingResource = true; sharingResource = true;
} }
UiObject search = getUiObjectByText("Search", "android.widget.EditText"); UiObject search = getUiObjectByText("Search", "android.widget.EditText");
search.setText(name); search.setText(name);
UiObject peopleItem = getUiObjectByText(name, "android.widget.TextView"); UiObject peopleItem = clickUiObject(BY_TEXT, name, "android.widget.TextView");
peopleItem.waitForExists(uiAutoTimeout);
peopleItem.click();
UiObject avatarPresence = UiObject avatarPresence =
new UiObject(new UiSelector().resourceId(packageID + "skype_avatar_presence")); new UiObject(new UiSelector().resourceId(packageID + "skype_avatar_presence"));
UiObject confirm =
new UiObject(new UiSelector().resourceId(packageID + "fab"));
// On some devices two clicks are needed to select a contact. // On some devices two clicks are needed to select a contact.
if (!avatarPresence.waitUntilGone(uiAutoTimeout)) { if (!avatarPresence.waitUntilGone(uiAutoTimeout)) {
peopleItem.click(); if (!sharingResource || !confirm.exists()) {
peopleItem.click();
}
} }
// Before sharing a resource from another app we first need to // Before sharing a resource from another app we first need to
// confirm our selection. // confirm our selection.
if (sharingResource) { if (sharingResource) {
UiObject confirm =
new UiObject(new UiSelector().resourceId(packageID + "fab"));
confirm.click(); confirm.click();
} }
} }
@ -158,15 +157,11 @@ public class UiAutomation extends UxPerfUiAutomation {
e.printStackTrace(); e.printStackTrace();
} }
Long viewTimeout = TimeUnit.SECONDS.toMillis(10); return dismissButton.waitUntilGone(TimeUnit.SECONDS.toMillis(10));
boolean dismissed = dismissButton.waitUntilGone(viewTimeout);
return dismissed;
} }
return false; return false;
} }
}; };
return infoPopUpWatcher; return infoPopUpWatcher;
} }
@ -191,11 +186,14 @@ public class UiAutomation extends UxPerfUiAutomation {
private void makeCall(int duration, boolean video, String testTag) throws Exception { private void makeCall(int duration, boolean video, String testTag) throws Exception {
String description = video ? "Video call" : "Call options"; String description = video ? "Video call" : "Call options";
UiObject callButton = new UiObject(new UiSelector().descriptionContains(description)); UiObject callButton =
new UiObject(new UiSelector().descriptionContains(description));
callButton.clickAndWaitForNewWindow(); callButton.clickAndWaitForNewWindow();
UiObject muteButton = new UiObject(new UiSelector().descriptionContains("Mute")); UiObject muteButton =
new UiObject(new UiSelector().descriptionContains("Mute"));
muteButton.click(); muteButton.click();
sleep(duration); sleep(duration);
} }
} }