Skip to content

Commit 345d9e0

Browse files
author
Qais Yousef
committed
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 <[email protected]>
1 parent b109aca commit 345d9e0

File tree

1 file changed

+26
-3
lines changed

1 file changed

+26
-3
lines changed

wa/workloads/uibench/__init__.py

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ class Uibench(ApkWorkload):
3939
recommend using the APK of UIBench corresponding to the
4040
Android version, enforced through the ``version`` parameter to
4141
this workload.
42+
You can provide multiple activities to run by separating them
43+
with white space.
4244
"""),
4345
Parameter('duration', kind=int, default=10,
4446
description="""
@@ -47,6 +49,27 @@ class Uibench(ApkWorkload):
4749
"""),
4850
]
4951

50-
def run(self, context):
51-
super(Uibench, self).run(context)
52-
self.target.sleep(self.duration)
52+
def __init__(self, target, **kwargs):
53+
super(Uibench, self).__init__(target, **kwargs)
54+
if self.activity:
55+
activities = self.activity.split()
56+
self.activity = ''
57+
for activity in activities:
58+
if '.' not in activity:
59+
# If we're receiving just the activity name, it's taken relative to
60+
# the package namespace:
61+
self.activity += ' .' + activity
62+
else:
63+
self.activity += ' ' + activity
64+
65+
def setup(self, context):
66+
if self.activity:
67+
activities = self.activity.split()
68+
for activity in activities:
69+
self.apk._activity = activity
70+
self.logger.info("Starting {} for {} seconds".format(activity, self.duration))
71+
super(Uibench, self).setup(context)
72+
self.target.sleep(self.duration)
73+
else:
74+
super(Uibench, self).setup(context)
75+
self.target.sleep(self.duration)

0 commit comments

Comments
 (0)