mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-30 06:34:13 +00:00 
			
		
		
		
	Add Skype workload
This commit is contained in:
		
							
								
								
									
										99
									
								
								wlauto/workloads/skype/__init__.py
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										99
									
								
								wlauto/workloads/skype/__init__.py
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,99 @@ | ||||
| #    Copyright 2014-2016 ARM Limited | ||||
| # | ||||
| # Licensed under the Apache License, Version 2.0 (the "License"); | ||||
| # you may not use this file except in compliance with the License. | ||||
| # You may obtain a copy of the License at | ||||
| # | ||||
| #     http://www.apache.org/licenses/LICENSE-2.0 | ||||
| # | ||||
| # Unless required by applicable law or agreed to in writing, software | ||||
| # distributed under the License is distributed on an "AS IS" BASIS, | ||||
| # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
| # See the License for the specific language governing permissions and | ||||
| # limitations under the License. | ||||
| # | ||||
|  | ||||
| import time | ||||
| from wlauto import AndroidUxPerfWorkload, Parameter | ||||
|  | ||||
|  | ||||
| class Skype(AndroidUxPerfWorkload): | ||||
|  | ||||
|     name = 'skype' | ||||
|     description = ''' | ||||
|     A workload to perform standard productivity tasks within Skype. The | ||||
|     workload logs in to the Skype application, selects a recipient from the | ||||
|     contacts list and then initiates either a voice or video call. | ||||
|  | ||||
|     Test description: | ||||
|  | ||||
|     1. Open Skype application | ||||
|     2. Log in to a pre-defined account | ||||
|     3. Select a recipient from the Contacts list | ||||
|     4. Initiate either a ``voice`` or ``video`` call for ``duration`` time (in seconds) | ||||
|  | ||||
|     **Skype Setup** | ||||
|  | ||||
|        - You should install Skype client from Google Play Store on the device | ||||
|          (this was tested with client version 7.01.0.669; other recent versions | ||||
|          should also work). | ||||
|        - You must have a Skype account set up. | ||||
|        - The contact to be called must be added (and has accepted) to the | ||||
|          account. It's possible to have multiple contacts in the list, however | ||||
|          the contact to be called *must* be visible on initial navigation to the | ||||
|          list. | ||||
|        - For video calls the contact must be able to received the call. This | ||||
|          means that there must be  a Skype client running (somewhere) with the | ||||
|          contact logged in and that client must have been configured to | ||||
|          auto-accept calls from the account on the device (how to set this | ||||
|          varies between different versions of Skype and between platforms -- | ||||
|          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 | ||||
|     ''' | ||||
|     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 | ||||
|  | ||||
|     parameters = [ | ||||
|         Parameter('login_name', kind=str, mandatory=True, | ||||
|                   description=''' | ||||
|                   Account to use when logging into the device from which the call will be made | ||||
|                   '''), | ||||
|         Parameter('login_pass', kind=str, mandatory=True, | ||||
|                   description='Password associated with the account to log into the device'), | ||||
|         Parameter('contact_name', kind=str, mandatory=True, default='Echo / Sound Test Service', | ||||
|                   description='This is the contact display name as it appears in the people list'), | ||||
|         Parameter('duration', kind=int, default=10, | ||||
|                   description='This is the duration of the call in seconds'), | ||||
|         Parameter('action', kind=str, allowed_values=['voice', 'video'], default='voice', | ||||
|                   description='Action to take - either voice call (default) or video'), | ||||
|     ] | ||||
|  | ||||
|     # This workload relies on the internet so check that there is a working | ||||
|     # internet connection | ||||
|     requires_network = True | ||||
|  | ||||
|     def __init__(self, device, **kwargs): | ||||
|         super(Skype, self).__init__(device, **kwargs) | ||||
|         self.run_timeout = self.duration + 240 | ||||
|  | ||||
|     def validate(self): | ||||
|         super(Skype, self).validate() | ||||
|         self.uiauto_params['my_id'] = self.login_name | ||||
|         self.uiauto_params['my_pwd'] = self.login_pass | ||||
|         self.uiauto_params['name'] = self.contact_name.replace(' ', '0space0') | ||||
|         self.uiauto_params['duration'] = self.duration | ||||
|         self.uiauto_params['action'] = self.action | ||||
|  | ||||
|     def setup(self, context): | ||||
|         super(Skype, self).setup(context) | ||||
|         self.device.execute('am start -W -a android.intent.action.VIEW -d skype:dummy?dummy') | ||||
							
								
								
									
										
											BIN
										
									
								
								wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								wlauto/workloads/skype/com.arm.wlauto.uiauto.skype.jar
									
									
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										39
									
								
								wlauto/workloads/skype/uiauto/build.sh
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										39
									
								
								wlauto/workloads/skype/uiauto/build.sh
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,39 @@ | ||||
| #!/bin/bash | ||||
|  | ||||
| # CD into build dir if possible - allows building from any directory | ||||
| script_path='.' | ||||
| if `readlink -f $0 &>/dev/null`; then | ||||
|     script_path=`readlink -f $0 2>/dev/null` | ||||
| fi | ||||
| script_dir=`dirname $script_path` | ||||
| cd $script_dir | ||||
|  | ||||
| # Ensure build.xml exists before starting | ||||
| if [[ ! -f build.xml ]]; then | ||||
|     echo 'Ant build.xml file not found! Check that you are in the right directory.' | ||||
|     exit 9 | ||||
| fi | ||||
|  | ||||
| # Copy base classes from wlauto dist | ||||
| class_dir=bin/classes/com/arm/wlauto/uiauto | ||||
| base_classes=`python -c "import os, wlauto; print os.path.join(os.path.dirname(wlauto.__file__), 'common', 'android', '*.class')"` | ||||
| mkdir -p $class_dir | ||||
| cp $base_classes $class_dir | ||||
|  | ||||
| # Build and return appropriate exit code if failed | ||||
| ant build | ||||
| exit_code=$? | ||||
| if [[ $exit_code -ne 0 ]]; then | ||||
|     echo "ERROR: 'ant build' exited with code $exit_code" | ||||
|     exit $exit_code | ||||
| fi | ||||
|  | ||||
| # If successful move JAR file to workload folder (overwrite previous) | ||||
| package=com.arm.wlauto.uiauto.skype.jar | ||||
| rm -f ../$package | ||||
| if [[ -f bin/$package ]]; then | ||||
|     cp bin/$package .. | ||||
| else | ||||
|     echo 'ERROR: UiAutomator JAR could not be found!' | ||||
|     exit 9 | ||||
| fi | ||||
							
								
								
									
										92
									
								
								wlauto/workloads/skype/uiauto/build.xml
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										92
									
								
								wlauto/workloads/skype/uiauto/build.xml
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,92 @@ | ||||
| <?xml version="1.0" encoding="UTF-8"?> | ||||
| <project name="com.arm.wlauto.uiauto.skype" default="help"> | ||||
|  | ||||
|     <!-- The local.properties file is created and updated by the 'android' tool. | ||||
|          It contains the path to the SDK. It should *NOT* be checked into | ||||
|          Version Control Systems. --> | ||||
|     <property file="local.properties" /> | ||||
|  | ||||
|     <!-- The ant.properties file can be created by you. It is only edited by the | ||||
|          'android' tool to add properties to it. | ||||
|          This is the place to change some Ant specific build properties. | ||||
|          Here are some properties you may want to change/update: | ||||
|  | ||||
|          source.dir | ||||
|              The name of the source directory. Default is 'src'. | ||||
|          out.dir | ||||
|              The name of the output directory. Default is 'bin'. | ||||
|  | ||||
|          For other overridable properties, look at the beginning of the rules | ||||
|          files in the SDK, at tools/ant/build.xml | ||||
|  | ||||
|          Properties related to the SDK location or the project target should | ||||
|          be updated using the 'android' tool with the 'update' action. | ||||
|  | ||||
|          This file is an integral part of the build system for your | ||||
|          application and should be checked into Version Control Systems. | ||||
|  | ||||
|          --> | ||||
|     <property file="ant.properties" /> | ||||
|  | ||||
|     <!-- if sdk.dir was not set from one of the property file, then | ||||
|          get it from the ANDROID_HOME env var. | ||||
|          This must be done before we load project.properties since | ||||
|          the proguard config can use sdk.dir --> | ||||
|     <property environment="env" /> | ||||
|     <condition property="sdk.dir" value="${env.ANDROID_HOME}"> | ||||
|         <isset property="env.ANDROID_HOME" /> | ||||
|     </condition> | ||||
|  | ||||
|     <!-- The project.properties file is created and updated by the 'android' | ||||
|          tool, as well as ADT. | ||||
|  | ||||
|          This contains project specific properties such as project target, and library | ||||
|          dependencies. Lower level build properties are stored in ant.properties | ||||
|          (or in .classpath for Eclipse projects). | ||||
|  | ||||
|          This file is an integral part of the build system for your | ||||
|          application and should be checked into Version Control Systems. --> | ||||
|     <loadproperties srcFile="project.properties" /> | ||||
|  | ||||
|     <!-- quick check on sdk.dir --> | ||||
|     <fail | ||||
|             message="sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable." | ||||
|             unless="sdk.dir" | ||||
|     /> | ||||
|  | ||||
|     <!-- | ||||
|         Import per project custom build rules if present at the root of the project. | ||||
|         This is the place to put custom intermediary targets such as: | ||||
|             -pre-build | ||||
|             -pre-compile | ||||
|             -post-compile (This is typically used for code obfuscation. | ||||
|                            Compiled code location: ${out.classes.absolute.dir} | ||||
|                            If this is not done in place, override ${out.dex.input.absolute.dir}) | ||||
|             -post-package | ||||
|             -post-build | ||||
|             -pre-clean | ||||
|     --> | ||||
|     <import file="custom_rules.xml" optional="true" /> | ||||
|  | ||||
|     <!-- Import the actual build file. | ||||
|  | ||||
|          To customize existing targets, there are two options: | ||||
|          - Customize only one target: | ||||
|              - copy/paste the target into this file, *before* the | ||||
|                <import> task. | ||||
|              - customize it to your needs. | ||||
|          - Customize the whole content of build.xml | ||||
|              - copy/paste the content of the rules files (minus the top node) | ||||
|                into this file, replacing the <import> task. | ||||
|              - customize to your needs. | ||||
|  | ||||
|          *********************** | ||||
|          ****** IMPORTANT ****** | ||||
|          *********************** | ||||
|          In all cases you must update the value of version-tag below to read 'custom' instead of an integer, | ||||
|          in order to avoid having your file be overridden by tools such as "android update project" | ||||
|     --> | ||||
|     <!-- version-tag: VERSION_TAG --> | ||||
|     <import file="${sdk.dir}/tools/ant/uibuild.xml" /> | ||||
|  | ||||
| </project> | ||||
							
								
								
									
										14
									
								
								wlauto/workloads/skype/uiauto/project.properties
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										14
									
								
								wlauto/workloads/skype/uiauto/project.properties
									
									
									
									
									
										Normal file
									
								
							| @@ -0,0 +1,14 @@ | ||||
| # This file is automatically generated by Android Tools. | ||||
| # Do not modify this file -- YOUR CHANGES WILL BE ERASED! | ||||
| # | ||||
| # This file must be checked in Version Control Systems. | ||||
| # | ||||
| # To customize properties used by the Ant build system edit | ||||
| # "ant.properties", and override values to adapt the script to your | ||||
| # project structure. | ||||
| # | ||||
| # To enable ProGuard to shrink and obfuscate your code, uncomment this (available properties: sdk.dir, user.home): | ||||
| #proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt | ||||
|  | ||||
| # Project target. | ||||
| target=android-18 | ||||
| @@ -0,0 +1,183 @@ | ||||
| /*    Copyright 2014-2016 ARM Limited | ||||
|  * | ||||
|  * Licensed under the Apache License, Version 2.0 (the "License"); | ||||
|  * you may not use this file except in compliance with the License. | ||||
|  * You may obtain a copy of the License at | ||||
|  * | ||||
|  *     http://www.apache.org/licenses/LICENSE-2.0 | ||||
|  * | ||||
|  * Unless required by applicable law or agreed to in writing, software | ||||
|  * distributed under the License is distributed on an "AS IS" BASIS, | ||||
|  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||||
|  * See the License for the specific language governing permissions and | ||||
|  * limitations under the License. | ||||
|  */ | ||||
|  | ||||
| package com.arm.wlauto.uiauto.skype; | ||||
|  | ||||
| import android.os.Bundle; | ||||
|  | ||||
| // Import the uiautomator libraries | ||||
| import com.android.uiautomator.core.UiObject; | ||||
| import com.android.uiautomator.core.UiObjectNotFoundException; | ||||
| import com.android.uiautomator.core.UiSelector; | ||||
| import com.android.uiautomator.core.UiWatcher; | ||||
| import com.arm.wlauto.uiauto.UxPerfUiAutomation; | ||||
|  | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| public class UiAutomation extends UxPerfUiAutomation { | ||||
|  | ||||
|     public static final String TEXT_VIEW = "android.widget.TextView"; | ||||
|  | ||||
|     public Bundle parameters; | ||||
|     public String packageName; | ||||
|     public String packageID; | ||||
|  | ||||
|     // Creates a watcher for when a pop up dialog appears with a dismiss button. | ||||
|     private UiWatcher createInfoPopUpWatcher() throws Exception { | ||||
|         UiWatcher infoPopUpWatcher = new UiWatcher() { | ||||
|             @Override | ||||
|             public boolean checkForCondition() { | ||||
|                 UiObject dismissButton = | ||||
|                     new UiObject(new UiSelector().resourceId(packageID + "dismiss_button")); | ||||
|  | ||||
|                 if (dismissButton.exists()) { | ||||
|                     try { | ||||
|                         dismissButton.click(); | ||||
|                     } catch (UiObjectNotFoundException e) { | ||||
|                         e.printStackTrace(); | ||||
|                     } | ||||
|  | ||||
|                     Long viewTimeout = TimeUnit.SECONDS.toMillis(10); | ||||
|                     boolean dismissed = dismissButton.waitUntilGone(viewTimeout); | ||||
|  | ||||
|                     return dismissed; | ||||
|                 } | ||||
|                 return false; | ||||
|             } | ||||
|         }; | ||||
|  | ||||
|         return infoPopUpWatcher; | ||||
|     } | ||||
|  | ||||
|     public void runUiAutomation() throws Exception { | ||||
|         // Override superclass value | ||||
|         this.uiAutoTimeout = TimeUnit.SECONDS.toMillis(10); | ||||
|  | ||||
|         // Get Params | ||||
|         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); | ||||
|  | ||||
|         UiWatcher infoPopUpWatcher = createInfoPopUpWatcher(); | ||||
|         registerWatcher("infoPopUpWatcher", infoPopUpWatcher); | ||||
|         runWatchers(); | ||||
|  | ||||
|         // Run tests | ||||
|         handleLoginScreen(loginName, loginPass); | ||||
|         searchForContact(contactName); | ||||
|  | ||||
|         if ("video".equalsIgnoreCase(callType)) { | ||||
|             videoCallTest(callDuration); | ||||
|         } else if ("voice".equalsIgnoreCase(callType)) { | ||||
|             voiceCallTest(callDuration); | ||||
|         } | ||||
|  | ||||
|         removeWatcher("infoPopUpWatcher"); | ||||
|         unsetScreenOrientation(); | ||||
|     } | ||||
|  | ||||
|     public void handleLoginScreen(String username, String password) throws Exception { | ||||
|         String useridResoureId = packageID + "sign_in_userid"; | ||||
|         String nextButtonResourceId = packageID + "sign_in_next_btn"; | ||||
|         UiObject useridField = new UiObject(new UiSelector().resourceId(useridResoureId)); | ||||
|         UiObject nextButton = new UiObject(new UiSelector().resourceId(nextButtonResourceId)); | ||||
|         useridField.setText(username); | ||||
|         nextButton.clickAndWaitForNewWindow(); | ||||
|  | ||||
|         String passwordResoureId = packageID + "signin_password"; | ||||
|         String signinButtonResourceId = packageID + "sign_in_btn"; | ||||
|         UiObject passwordField = new UiObject(new UiSelector().resourceId(passwordResoureId)); | ||||
|         UiObject signinButton = new UiObject(new UiSelector().resourceId(signinButtonResourceId)); | ||||
|         passwordField.setText(password); | ||||
|         signinButton.clickAndWaitForNewWindow(); | ||||
|     } | ||||
|  | ||||
|     public void searchForContact(String name) throws Exception { | ||||
|         UiObject menuSearch = new UiObject(new UiSelector().resourceId(packageID + "menu_search")); | ||||
|         boolean sharingResource = false; | ||||
|  | ||||
|         // If searching for a contact from Skype directly we need | ||||
|         // to click the menu search button to display the contact search box. | ||||
|         if (menuSearch.waitForExists(uiAutoTimeout)) { | ||||
|             menuSearch.click(); | ||||
|  | ||||
|         // If sharing a resource from another app the contact search box is shown | ||||
|         // by default. | ||||
|         } else { | ||||
|             sharingResource = true; | ||||
|         } | ||||
|  | ||||
|         UiObject search = getUiObjectByText("Search", "android.widget.EditText"); | ||||
|         search.setText(name); | ||||
|  | ||||
|         UiObject peopleItem = getUiObjectByText(name, "android.widget.TextView"); | ||||
|  | ||||
|         peopleItem.waitForExists(uiAutoTimeout); | ||||
|         peopleItem.click(); | ||||
|  | ||||
|         UiObject avatarPresence = | ||||
|             new UiObject(new UiSelector().resourceId(packageID + "skype_avatar_presence")); | ||||
|  | ||||
|         // On some devices two clicks are needed to select a contact. | ||||
|         if (!avatarPresence.waitUntilGone(uiAutoTimeout)) { | ||||
|             peopleItem.click(); | ||||
|         } | ||||
|  | ||||
|         // Before sharing a resource from another app we first need to | ||||
|         // confirm our selection. | ||||
|         if (sharingResource) { | ||||
|             UiObject confirm = | ||||
|                 new UiObject(new UiSelector().resourceId(packageID + "fab")); | ||||
|             confirm.click(); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     private void voiceCallTest(int duration) throws Exception { | ||||
|         String testTag = "call_voice"; | ||||
|         ActionLogger logger = new ActionLogger(testTag, parameters); | ||||
|  | ||||
|         logger.start(); | ||||
|         makeCall(duration, false, testTag); | ||||
|         logger.stop(); | ||||
|     } | ||||
|  | ||||
|     private void videoCallTest(int duration) throws Exception { | ||||
|         String testTag = "call_video"; | ||||
|         ActionLogger logger = new ActionLogger(testTag, parameters); | ||||
|  | ||||
|         logger.start(); | ||||
|         makeCall(duration, true, testTag); | ||||
|         logger.stop(); | ||||
|     } | ||||
|  | ||||
|     private void makeCall(int duration, boolean video, String testTag) throws Exception { | ||||
|         String description = video ? "Video call" : "Call options"; | ||||
|  | ||||
|         UiObject callButton = new UiObject(new UiSelector().descriptionContains(description)); | ||||
|         callButton.clickAndWaitForNewWindow(); | ||||
|  | ||||
|         UiObject muteButton = new UiObject(new UiSelector().descriptionContains("Mute")); | ||||
|         muteButton.click(); | ||||
|         sleep(duration); | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user