Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update uiauto library, extend framework to allow jank-testing and add new JetNews jank-testing workload #1268

Open
wants to merge 17 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
510b344
[framework/uiauto] Update uiauto library to move away from android.su…
luis-machado-arm Jul 3, 2024
18d9f94
[framework/workload] Add support for jank testing
luis-machado-arm Jul 8, 2024
b38e64a
[workloads] Add JetNews jank tests workload
luis-machado-arm Jul 4, 2024
1a308b6
[framework/uiauto] Revert changes to original uiauto library
luis-machado-arm Jul 26, 2024
9212b7f
[workload/JetNews] Address reviewer comments
luis-machado-arm Jul 26, 2024
761cab1
[workload/JetNews] Update timestamp for gradle-wrapper.properties file.
luis-machado-arm Aug 27, 2024
94fa1be
[framework/uiauto-androidx] Update copyright years
luis-machado-arm Aug 27, 2024
aa41d4d
[framework] Undo changes to UiAutomatorGUI
luis-machado-arm Aug 28, 2024
7b53b98
[framework] Create new Jank testing classes
luis-machado-arm Aug 28, 2024
fefaa3c
[workload/jetnews] Use Jank testing classes to implement jank testing…
luis-machado-arm Aug 28, 2024
e046461
[workloads/jetnews] Add missing self reference
luis-machado-arm Aug 29, 2024
77b3dfc
Fix linters/tests CI issues
luis-machado-arm Aug 29, 2024
651fd23
[workloads/jetnews] Disable too-many-ancestors linter for Jetnews class
luis-machado-arm Sep 13, 2024
e85cca9
[workloads/jetnews] Fix more linter issues (E302 and E261)
luis-machado-arm Sep 13, 2024
5180fed
[workloads/jetnews] Harden JetNews testing to cope with tablets/small…
luis-machado-arm Nov 5, 2024
c9ffbfb
[workloads/jetnews] Improve reliability of object detection
luis-machado-arm Nov 13, 2024
0cdccc1
[workloads/jetnews] Restore test default timeout, repeat count and fl…
luis-machado-arm Nov 13, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
93 changes: 93 additions & 0 deletions wa/workloads/jetnews/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Copyright 2024 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.
#

from wa import ApkUiautoWorkload, Parameter, TestPackageHandler
from wa.utils.types import list_of_strs
import re
luis-machado-arm marked this conversation as resolved.
Show resolved Hide resolved

class Jetnews(ApkUiautoWorkload):

name = 'jetnews'
package_names = ['com.example.jetnews']
description = '''
JetNews
luis-machado-arm marked this conversation as resolved.
Show resolved Hide resolved
'''

default_test_strings = [
'PortraitVerticalTest',
'PortraitHorizontalTest',
'LandscapeVerticalTest',
]

parameters = [
Parameter('tests', kind=list_of_strs,
description="""
List of tests to be executed. The available
tests are PortraitVerticalTest, LandscapeVerticalTest and
PortraitHorizontalTest. If none are specified, the default
is to run all of them.
""", default=default_test_strings),
Parameter('flingspeed', kind=int,
description="""
Default fling speed for the tests. The default is 5000 and
the minimum value is 1000.
""", default=5000),
luis-machado-arm marked this conversation as resolved.
Show resolved Hide resolved
Parameter('repeat', kind=int,
description="""
The number of times the tests should be repeated. The default
is 1.
""", default=1)
]

_OUTPUT_SECTION_REGEX = re.compile(
luis-machado-arm marked this conversation as resolved.
Show resolved Hide resolved
r'(\s*INSTRUMENTATION_STATUS: gfx-[\w-]+=[-+\d.]+\n)+'
r'\s*INSTRUMENTATION_STATUS_CODE: (?P<code>[-+\d]+)\n?', re.M)
_OUTPUT_GFXINFO_REGEX = re.compile(
r'INSTRUMENTATION_STATUS: (?P<name>[\w-]+)=(?P<value>[-+\d.]+)')

def __init__(self, target, **kwargs):
super(Jetnews, self).__init__(target, **kwargs)
# This test uses the androidx library.
self.gui.uiauto_runner = 'androidx.test.runner.AndroidJUnitRunner'
# Class for the regular instrumented tests.
self.gui.uiauto_class = 'UiAutomation'
# Class containing the jank tests.
self.gui.uiauto_jank_class = 'UiAutomationJankTests'
# A list of all the individual jank tests contained in the jetnews
# uiauto apk.
self.gui.jank_stages = ['test1']
self.gui.uiauto_params['tests'] = self.tests
self.gui.uiauto_params['flingspeed'] = self.flingspeed
self.gui.uiauto_params['repeat'] = self.repeat
# Declared here so we can hold the test output for later processing.
self.output = {}

def run(self, context):
# Run the jank tests and capture the output so we can parse it
# into the output result file.
self.output['test1'] = self.gui._execute('test1', self.gui.timeout)

def update_output(self, context):
super(Jetnews, self).update_output(context)
# Parse the test result and filter out the results so we can output
# a meaningful result file.
for test, test_output in self.output.items():
for section in self._OUTPUT_SECTION_REGEX.finditer(test_output):
if int(section.group('code')) != -1:
msg = 'Run failed (INSTRUMENTATION_STATUS_CODE: {}). See log.'
raise RuntimeError(msg.format(section.group('code')))
for metric in self._OUTPUT_GFXINFO_REGEX.finditer(section.group()):
context.add_metric(metric.group('name'), metric.group('value'),
classifiers={'test_name': test})
Binary file not shown.
51 changes: 51 additions & 0 deletions wa/workloads/jetnews/uiauto/app/build.gradle
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
plugins {
id 'com.android.application'
id "org.jetbrains.kotlin.android" version "2.0.20-Beta1"
}

kotlin {
// Standardize on the same jvm version for compatibility reasons.
jvmToolchain(17)
}

//apply plugin: 'com.android.application'
def packageName = "com.arm.wa.uiauto.jetnews"

android {
namespace = "com.arm.wa.uiauto.jetnews"

compileSdkVersion 34
defaultConfig {
applicationId "${packageName}"
minSdkVersion 23
targetSdkVersion 28
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
applicationVariants.all { variant ->
variant.outputs.each { output ->
output.outputFileName = "${packageName}.apk"
}
}
}
useLibrary 'android.test.base'
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.test.uiautomator:uiautomator:2.4.0-alpha01'
implementation 'androidx.test.janktesthelper:janktesthelper:1.0.1'
implementation 'androidx.test.espresso:espresso-core:3.5.1'

implementation(name: 'uiauto', ext: 'aar')
}

repositories {
flatDir {
dirs 'libs'
}
}

tasks.withType(JavaCompile) {
options.compilerArgs += ['-Xlint:deprecation']
}
11 changes: 11 additions & 0 deletions wa/workloads/jetnews/uiauto/app/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
android:versionCode="1"
android:versionName="1.0">


<instrumentation
android:name="androidx.test.runner.AndroidJUnitRunner"
android:targetPackage="${applicationId}"/>

</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
/* Copyright 2014-2024 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.
*/

package com.arm.wa.uiauto.jetnews;

import androidx.test.uiautomator.UiObject;
import androidx.test.uiautomator.UiSelector;

import android.os.Bundle;

import com.arm.wa.uiauto.ApplaunchInterface;
import com.arm.wa.uiauto.BaseUiAutomation;
import com.arm.wa.uiauto.UiAutoUtils;

import org.junit.Test;

// Dummy workload for jetnews. We need to use JankTestBasem but we
luis-machado-arm marked this conversation as resolved.
Show resolved Hide resolved
// can't inherit from that class as we already inherit BaseUiAutomation.
// Therefore we have another class (UiAutomationJankTests) that uses
// this class instead.

public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface {

protected Bundle parameters;
protected String packageID;

public void initialize() {
parameters = getParams();
packageID = getPackageID(parameters);
}

@Test
public void setup() throws Exception {
setScreenOrientation(ScreenOrientation.NATURAL);
}

@Test
public void runWorkload() {
// Intentionally empty, not used.
}

@Test
public void teardown() throws Exception {
unsetScreenOrientation();
}

public void runApplicationSetup() throws Exception {
// Intentionally empty, not used.
}

// Sets the UiObject that marks the end of the application launch.
public UiObject getLaunchEndObject() {
// Intentionally empty, not used.
return null;
}

// Returns the launch command for the application.
public String getLaunchCommand() {
// Intentionally empty, not used.
return "";
}

// Pass the workload parameters, used for applaunch
public void setWorkloadParameters(Bundle workload_parameters) {
// Intentionally empty, not used.
}
}


Loading
Loading