From e1860561821e2aae15e1a87bd826f2c1eda525c1 Mon Sep 17 00:00:00 2001 From: Marc Bonnici Date: Fri, 9 Jun 2017 10:32:55 +0100 Subject: [PATCH] Workload: Adds workload parameters for APKHandler Now accepts parameters which can be used to determine which apk is to be used and to control the apk installation procedure. --- wa/framework/workload.py | 53 ++++++++++++++++++++++++++++++++++++++-- 1 file changed, 51 insertions(+), 2 deletions(-) diff --git a/wa/framework/workload.py b/wa/framework/workload.py index e8a8574c..9216e775 100644 --- a/wa/framework/workload.py +++ b/wa/framework/workload.py @@ -17,6 +17,7 @@ import os import re import time +from wa import Parameter from wa.framework.plugin import TargetedPlugin from wa.framework.resource import (ApkFile, JarFile, ReventFile, NO_ONE, Executable, File) @@ -142,9 +143,57 @@ class ApkUiautoWorkload(ApkUIWorkload): platform = 'android' + parameters = [ + Parameter('package', kind=str, + description=""" + The pacakge name that can be used to specify + the workload apk to use. + """), + Parameter('install_timeout', kind=int, + constraint=lambda x: x > 0, + default=300, + description=""" + Timeout for the installation of the apk. + """), + Parameter('version', kind=str, + default=None, + description=""" + The version of the package to be used. + """), + Parameter('variant', kind=str, + default=None, + description=""" + The variant of the package to be used. + """), + Parameter('strict', kind=bool, + default=False, + description=""" + Whether to throw and error if the specified package cannot be found + on host. + """), + Parameter('force_install', kind=bool, + default=False, + description=""" + Always re-install the APK, even if matching version is found already installed + on the device. + """), + Parameter('uninstall', kind=bool, + default=False, + description=""" + If ``True``, will uninstall workload\'s APK as part of teardown.' + """), + ] + def __init__(self, target, **kwargs): super(ApkUiautoWorkload, self).__init__(target, **kwargs) - self.apk = PackageHandler(self) + self.apk = PackageHandler(self, + package=self.package, + variant=self.variant, + strict=self.strict, + version=self.version, + force_install=self.force_install, + install_timeout=self.install_timeout, + uninstall=self.uninstall) self.gui = UiAutomatorGUI(self) @@ -282,7 +331,7 @@ class ReventGUI(object): self.revent_teardown_file = resolver.get(resource=ReventFile(owner=self.workload, stage='teardown', target=self.target.model), - strict=False) + strict=False) def deploy(self): self.revent_recorder.deploy()