From 9cb7ea862ce8bf3a152b85ab87d8c3f3234922f4 Mon Sep 17 00:00:00 2001 From: Sergei Trofimov Date: Fri, 29 Sep 2017 14:22:22 +0100 Subject: [PATCH] framework/workload: default view for ApkWorkload - Add "activity" property to PackageManager exposing the underlying apk_info attribute. - Add "view" class attribute to ApkWorkload, initialized to None - If "view" is not set for a particular workload, set a default based on the package and activity of the underlying workload. --- wa/framework/workload.py | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/wa/framework/workload.py b/wa/framework/workload.py index 5089479e..baaba343 100644 --- a/wa/framework/workload.py +++ b/wa/framework/workload.py @@ -99,12 +99,14 @@ class Workload(TargetedPlugin): def __str__(self): return ''.format(self.name) + class ApkWorkload(Workload): # May be optionally overwritten by subclasses # Times are in seconds loading_time = 10 package_names = [] + view = None parameters = [ Parameter('package_name', kind=str, @@ -175,6 +177,9 @@ class ApkWorkload(Workload): @once_per_instance def initialize(self, context): self.apk.initialize(context) + if self.view is None: + self.view = 'SurfaceView - {}/{}'.format(self.apk.package, + self.apk.activity) def setup(self, context): self.apk.setup(context) @@ -440,6 +445,12 @@ class PackageHandler(object): return None return self.apk_info.package + @property + def activity(self): + if self.apk_info is None: + return None + return self.apk_info.activity + def __init__(self, owner, install_timeout=300, version=None, variant=None, package_name=None, strict=False, force_install=False, uninstall=False, exact_abi=False):