1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-06 02:41:11 +01:00

Merge pull request #397 from marcbonnici/uiauto2

Uiautomator2: Fix for newer adb versions.
This commit is contained in:
setrofim 2017-06-08 10:57:49 +01:00 committed by GitHub
commit a4e27128e5
63 changed files with 46 additions and 59 deletions

View File

@ -390,10 +390,10 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
else:
return self.install_executable(filepath, with_name)
def install_apk(self, filepath, timeout=default_timeout, replace=False, allow_downgrade=False, force=False): # pylint: disable=W0221
def install_apk(self, filepath, timeout=default_timeout, replace=False, allow_downgrade=False): # pylint: disable=W0221
self._check_ready()
ext = os.path.splitext(filepath)[1].lower()
if ext == '.apk' or force:
if ext == '.apk':
flags = []
if replace:
flags.append('-r') # Replace existing APK

View File

@ -35,21 +35,11 @@ class ApkFile(FileResource):
name = 'apk'
def __init__(self, owner, platform=None):
def __init__(self, owner, platform=None, uiauto=False):
super(ApkFile, self).__init__(owner)
self.platform = platform
self.uiauto = uiauto
def __str__(self):
return '<{}\'s {} APK>'.format(self.owner, self.platform)
class uiautoApkFile(FileResource):
name = 'uiautoapk'
def __init__(self, owner, platform=None):
super(uiautoApkFile, self).__init__(owner)
self.platform = platform
def __str__(self):
return '<{}\'s {} UiAuto APK>'.format(self.owner, self.platform)
apk_type = 'uiautomator ' if self.uiauto else ''
return '<{}\'s {} {}APK>'.format(self.owner, self.platform, apk_type)

View File

@ -84,7 +84,7 @@ class UiAutomatorWorkload(Workload):
self.uiauto_params = ParameterDict()
def init_resources(self, context):
self.uiauto_file = context.resolver.get(wlauto.common.android.resources.uiautoApkFile(self))
self.uiauto_file = context.resolver.get(ApkFile(self, uiauto=True))
if not self.uiauto_file:
raise ResourceError('No UI automation APK file found for workload {}.'.format(self.name))
@ -99,7 +99,7 @@ class UiAutomatorWorkload(Workload):
for k, v in self.uiauto_params.iter_encoded_items():
params += ' -e {} "{}"'.format(k, v)
self.device.install_apk(self.uiauto_file, replace=True, force=True)
self.device.install_apk(self.uiauto_file, replace=True)
instrumention_string = 'am instrument -w -r {} -e class {}.{} {}/{}'
self.command = instrumention_string.format(params, self.uiauto_package,

View File

@ -122,11 +122,6 @@ class PackageApkGetter(PackageFileGetter):
return get_from_location_by_extension(resource, resource_dir, self.extension, version, variant=variant)
class PackageUiautoApkGetter(PackageApkGetter):
name = 'uiautoapk'
extension = 'uiautoapk'
class PackageJarGetter(PackageFileGetter):
name = 'package_jar'
extension = 'jar'
@ -412,7 +407,7 @@ class HttpGetter(ResourceGetter):
assets = self.index.get(resource.owner.name, {})
if not assets:
return {}
if resource.name in ['apk', 'jar', 'uiautoapk']:
if resource.name in ['apk', 'jar']:
paths = [a['path'] for a in assets]
version = getattr(resource, 'version', None)
found = get_from_list_by_extension(resource, paths, resource.name, version)
@ -457,7 +452,7 @@ class RemoteFilerGetter(ResourceGetter):
"""
priority = GetterPriority.remote
resource_type = ['apk', 'file', 'jar', 'revent', 'uiautoapk']
resource_type = ['apk', 'file', 'jar', 'revent']
parameters = [
Parameter('remote_path', global_alias='remote_assets_path', default='',
@ -505,7 +500,7 @@ class RemoteFilerGetter(ResourceGetter):
def get_from(self, resource, version, location): # pylint: disable=no-self-use
# pylint: disable=too-many-branches
if resource.name in ['apk', 'jar', 'uiautoapk']:
if resource.name in ['apk', 'jar']:
return get_from_location_by_extension(resource, location, resource.name, version)
elif resource.name == 'file':
filepath = os.path.join(location, resource.path)
@ -562,12 +557,13 @@ def get_from_list_by_extension(resource, filelist, extension, version=None, vari
if variant:
filelist = [ff for ff in filelist if variant.lower() in os.path.basename(ff).lower()]
if version:
if extension in ['apk', 'uiautoapk']:
if extension == 'apk':
filelist = [ff for ff in filelist if version.lower() in ApkInfo(ff).version_name.lower()]
else:
filelist = [ff for ff in filelist if version.lower() in os.path.basename(ff).lower()]
if extension in ['apk', 'uiautoapk']:
if extension == 'apk':
filelist = [ff for ff in filelist if not ApkInfo(ff).native_code or resource.platform in ApkInfo(ff).native_code]
filelist = [ff for ff in filelist if resource.uiauto == ('com.arm.wlauto.uiauto' in ApkInfo(ff).package)]
if len(filelist) == 1:
return filelist[0]
elif not filelist:

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.adobereader
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.andebench
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.androbench
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.antutu
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -116,7 +116,7 @@ class Applaunch(AndroidUxPerfWorkload):
self.package = self.workload.package
def init_workload_resources(self, context):
self.workload.uiauto_file = context.resolver.get(wlauto.common.android.resources.uiautoApkFile(self.workload))
self.workload.uiauto_file = context.resolver.get(wlauto.common.android.resources.ApkFile(self.workload, uiauto=True))
if not self.workload.uiauto_file:
raise ResourceError('No UI automation Uiauto APK file found for workload {}.'.format(self.workload.name))
self.workload.device_uiauto_file = self.device.path.join(self.device.working_directory, os.path.basename(self.workload.uiauto_file))

View File

@ -34,7 +34,7 @@ package=com.arm.wlauto.uiauto.applaunch
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -46,7 +46,7 @@ fi
package=com.arm.wlauto.uiauto.appshare
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.benchmarkpi
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.caffeinemark
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.cameracapture
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.camerarecord
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.cfbench
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.facebook
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.geekbench
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.glbenchmark
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.gmail
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.googlephotos
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.googleplaybooks
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.googleslides
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.linpack
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.peacekeeper
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.quadrant
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.reallinpack
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.skype
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.smartbench
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.sqlite
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.vellamo
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -17,6 +17,7 @@
import os
from wlauto import AndroidUiAutoBenchmark, Parameter
from wlauto.common.android.resources import ApkFile
import wlauto.common.android.resources
@ -65,8 +66,8 @@ class Videostreaming(AndroidUiAutoBenchmark):
self.uiauto_params['video_name'] = self.video_name
else:
self.uiauto_params['video_name'] = "abkk sathe {}".format(self.resolution)
self.apk_file = context.resolver.get(wlauto.common.android.resources.ApkFile(self))
self.uiauto_file = context.resolver.get(wlauto.common.android.resources.uiautoApkFile(self))
self.apk_file = context.resolver.get(ApkFile(self))
self.uiauto_file = context.resolver.get(ApkFile(self, uiauto=True))
self.device_uiauto_file = self.device.path.join(self.device.working_directory,
os.path.basename(self.uiauto_file))
if not self.uiauto_package:

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.videostreaming
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9

View File

@ -33,7 +33,7 @@ fi
package=com.arm.wlauto.uiauto.youtube
rm -f ../$package
if [[ -f app/build/apk/$package.apk ]]; then
cp app/build/apk/$package.apk ../$package.uiautoapk
cp app/build/apk/$package.apk ../$package.apk
else
echo 'ERROR: UiAutomator apk could not be found!'
exit 9