mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-02-20 20:09:11 +00:00
commit
9222257d79
@ -32,7 +32,7 @@ from wlauto.utils.android import (adb_shell, adb_background_shell, adb_list_devi
|
||||
adb_command, AndroidProperties, ANDROID_VERSION_MAP)
|
||||
|
||||
|
||||
SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn)=([0-9]+|true|false)', re.I)
|
||||
SCREEN_STATE_REGEX = re.compile('(?:mPowerState|mScreenOn|Display Power: state)=([0-9]+|true|false|ON|OFF)', re.I)
|
||||
SCREEN_SIZE_REGEX = re.compile(r'mUnrestrictedScreen=\(\d+,\d+\)\s+(?P<width>\d+)x(?P<height>\d+)')
|
||||
|
||||
|
||||
@ -72,9 +72,10 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
||||
Specified whether the device should make sure that the screen is on
|
||||
during initialization.
|
||||
"""),
|
||||
Parameter('swipe_to_unlock', kind=boolean, default=False,
|
||||
Parameter('swipe_to_unlock', kind=str, default=None,
|
||||
allowed_values=[None, "horizontal", "vertical"],
|
||||
description="""
|
||||
If set to ``True``, a horisonal swipe will be performed 2/3 down the screen.
|
||||
If set a swipe of the specified direction will be performed.
|
||||
This should unlock the screen.
|
||||
"""),
|
||||
]
|
||||
@ -570,13 +571,20 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
||||
else:
|
||||
return (0, 0)
|
||||
|
||||
def swipe_to_unlock(self):
|
||||
def perform_unlock_swipe(self):
|
||||
width, height = self.get_screen_size()
|
||||
swipe_heigh = height * 2 // 3
|
||||
start = 100
|
||||
stop = width - start
|
||||
command = 'input swipe {} {} {} {}'
|
||||
self.execute(command.format(start, swipe_heigh, stop, swipe_heigh))
|
||||
if self.swipe_to_unlock == "horizontal":
|
||||
swipe_heigh = height * 2 // 3
|
||||
start = 100
|
||||
stop = width - start
|
||||
self.execute(command.format(start, swipe_heigh, stop, swipe_heigh))
|
||||
if self.swipe_to_unlock == "vertical":
|
||||
swipe_middle = height / 2
|
||||
swipe_heigh = height * 2 // 3
|
||||
self.execute(command.format(swipe_middle, swipe_heigh, swipe_middle, 0))
|
||||
else: # Should never reach here
|
||||
raise DeviceError("Invalid swipe direction: {}".format(self.swipe_to_unlock))
|
||||
|
||||
def capture_screen(self, filepath):
|
||||
"""Caputers the current device screen into the specified file in a PNG format."""
|
||||
@ -597,6 +605,8 @@ class AndroidDevice(BaseLinuxDevice): # pylint: disable=W0223
|
||||
def ensure_screen_is_on(self):
|
||||
if not self.is_screen_on():
|
||||
self.execute('input keyevent 26')
|
||||
if self.swipe_to_unlock:
|
||||
self.perform_unlock_swipe()
|
||||
|
||||
def disable_screen_lock(self):
|
||||
"""
|
||||
|
100
wlauto/workloads/recentfling/__init__.py
Normal file
100
wlauto/workloads/recentfling/__init__.py
Normal file
@ -0,0 +1,100 @@
|
||||
# Copyright 2013-2015 ARM Limited
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
|
||||
#pylint: disable=E1101,W0201
|
||||
|
||||
import os
|
||||
import re
|
||||
from collections import defaultdict
|
||||
|
||||
from wlauto import Workload, Parameter, File
|
||||
from wlauto.utils.types import caseless_string
|
||||
from wlauto.exceptions import WorkloadError
|
||||
|
||||
|
||||
class Recentfling(Workload):
|
||||
|
||||
name = 'recentfling'
|
||||
description = """
|
||||
Tests UI jank on android devices.
|
||||
|
||||
For this workload to work, ``recentfling.sh`` and ``defs.sh`` must be placed
|
||||
in ``~/.workload_automation/dependencies/recentfling/``. These can be found
|
||||
in the [AOSP Git repository](https://android.googlesource.com/platform/system/extras/+/master/tests/).
|
||||
|
||||
To change the apps that are opened at the start of the workload you will need
|
||||
to modify the ``defs.sh`` file. You will need to add your app to ``dfltAppList``
|
||||
and then add a variable called ``{app_name}Activity`` with the name of the
|
||||
activity to launch (where ``{add_name}`` is the name you put into ``dfltAppList``).
|
||||
|
||||
You can get a list of activities available on your device by running
|
||||
``adb shell pm list packages -f``
|
||||
"""
|
||||
supported_platforms = ['android']
|
||||
|
||||
parameters = [
|
||||
Parameter('loops', kind=int, default=3,
|
||||
description="The number of test iterations."),
|
||||
]
|
||||
|
||||
def initialise(self, context): # pylint: disable=no-self-use
|
||||
if context.device.get_sdk_version() >= 23:
|
||||
raise WorkloadError("This workload relies on ``dumpsys gfxinfo`` \
|
||||
only present in Android M and onwards")
|
||||
|
||||
def setup(self, context):
|
||||
self.defs_host = context.resolver.get(File(self, "defs.sh"))
|
||||
self.recentfling_host = context.resolver.get(File(self, "recentfling.sh"))
|
||||
self.device.push_file(self.recentfling_host, self.device.working_directory)
|
||||
self.device.push_file(self.defs_host, self.device.working_directory)
|
||||
self._kill_recentfling()
|
||||
self.device.ensure_screen_is_on()
|
||||
|
||||
def run(self, context):
|
||||
cmd = "echo $$>{dir}/pidfile; exec {dir}/recentfling.sh -i {}; rm {dir}/pidfile"
|
||||
cmd = cmd.format(self.loops, dir=self.device.working_directory)
|
||||
try:
|
||||
self.output = self.device.execute(cmd, timeout=120)
|
||||
except KeyboardInterrupt:
|
||||
self._kill_recentfling()
|
||||
raise
|
||||
|
||||
def update_result(self, context):
|
||||
group_names = ["90th Percentile", "95th Percentile", "99th Percentile", "Jank", "Jank%"]
|
||||
count = 0
|
||||
for line in self.output.strip().splitlines():
|
||||
p = re.compile("Frames: \d+ latency: (?P<pct90>\d+)/(?P<pct95>\d+)/(?P<pct99>\d+) Janks: (?P<jank>\d+)\((?P<jank_pct>\d+)%\)")
|
||||
match = p.search(line)
|
||||
if match:
|
||||
count += 1
|
||||
if line.startswith("AVE: "):
|
||||
group_names = ["Average " + g for g in group_names]
|
||||
count = 0
|
||||
for metric in zip(group_names, match.groups()):
|
||||
context.result.add_metric(metric[0],
|
||||
metric[1],
|
||||
None,
|
||||
classifiers={"loop": count or "Average"})
|
||||
|
||||
def teardown(self, context):
|
||||
self.device.delete_file(self.device.path.join(self.device.working_directory,
|
||||
"recentfling.sh"))
|
||||
self.device.delete_file(self.device.path.join(self.device.working_directory,
|
||||
"defs.sh"))
|
||||
|
||||
def _kill_recentfling(self):
|
||||
pid = self.device.execute('cat {}/pidfile'.format(self.device.working_directory))
|
||||
if pid:
|
||||
self.device.kill(pid.strip(), signal='SIGKILL')
|
Loading…
x
Reference in New Issue
Block a user