From 345d9e0a0d23eeb97adb88b4f3eadd4d64191d02 Mon Sep 17 00:00:00 2001 From: Qais Yousef Date: Fri, 15 Apr 2022 01:57:11 +0100 Subject: [PATCH] uibench: Support taking a list of activities It is desired to be able to run multiple activities with a single agenda file. We can make the @activity parameter take a list of activities separated by white space and run them all in one go. Each activity well run for the specified @duration. Signed-off-by: Qais Yousef --- wa/workloads/uibench/__init__.py | 29 ++++++++++++++++++++++++++--- 1 file changed, 26 insertions(+), 3 deletions(-) diff --git a/wa/workloads/uibench/__init__.py b/wa/workloads/uibench/__init__.py index b59bea1b..cadc91a4 100644 --- a/wa/workloads/uibench/__init__.py +++ b/wa/workloads/uibench/__init__.py @@ -39,6 +39,8 @@ class Uibench(ApkWorkload): recommend using the APK of UIBench corresponding to the Android version, enforced through the ``version`` parameter to this workload. + You can provide multiple activities to run by separating them + with white space. """), Parameter('duration', kind=int, default=10, description=""" @@ -47,6 +49,27 @@ class Uibench(ApkWorkload): """), ] - def run(self, context): - super(Uibench, self).run(context) - self.target.sleep(self.duration) + def __init__(self, target, **kwargs): + super(Uibench, self).__init__(target, **kwargs) + if self.activity: + activities = self.activity.split() + self.activity = '' + for activity in activities: + if '.' not in activity: + # If we're receiving just the activity name, it's taken relative to + # the package namespace: + self.activity += ' .' + activity + else: + self.activity += ' ' + activity + + def setup(self, context): + if self.activity: + activities = self.activity.split() + for activity in activities: + self.apk._activity = activity + self.logger.info("Starting {} for {} seconds".format(activity, self.duration)) + super(Uibench, self).setup(context) + self.target.sleep(self.duration) + else: + super(Uibench, self).setup(context) + self.target.sleep(self.duration)