1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-21 18:18:41 +00:00

antutu: Updated to support Antutu v6

This commit is contained in:
Sebastian Goscik 2016-01-08 16:14:43 +00:00
parent f1bb44b3e7
commit 09563bc01e
3 changed files with 91 additions and 29 deletions

View File

@ -16,7 +16,8 @@
import os import os
from collections import defaultdict, OrderedDict from collections import defaultdict, OrderedDict
from wlauto import AndroidUiAutoBenchmark, Parameter from wlauto import AndroidUiAutoBenchmark, Parameter, File
from wlauto.utils.android import ApkInfo
class Antutu(AndroidUiAutoBenchmark): class Antutu(AndroidUiAutoBenchmark):
@ -46,7 +47,7 @@ class Antutu(AndroidUiAutoBenchmark):
activity = ".ABenchMarkStart" activity = ".ABenchMarkStart"
summary_metrics = ['score', 'Overall_Score'] summary_metrics = ['score', 'Overall_Score']
valid_versions = ['3.3.2', '4.0.3', '5.3.0'] valid_versions = ['3.3.2', '4.0.3', '5.3.0', '6.0.1']
device_prefs_directory = '/data/data/com.antutu.ABenchMark/shared_prefs' device_prefs_directory = '/data/data/com.antutu.ABenchMark/shared_prefs'
device_prefs_file = '/'.join([device_prefs_directory, 'com.antutu.ABenchMark_preferences.xml']) device_prefs_file = '/'.join([device_prefs_directory, 'com.antutu.ABenchMark_preferences.xml'])
@ -68,18 +69,26 @@ class Antutu(AndroidUiAutoBenchmark):
def __init__(self, device, **kwargs): # pylint: disable=W0613 def __init__(self, device, **kwargs): # pylint: disable=W0613
super(Antutu, self).__init__(device, **kwargs) super(Antutu, self).__init__(device, **kwargs)
self.run_timeout = 6 * 60 * self.times self.run_timeout = 10 * 60 * self.times
self.uiauto_params['version'] = self.version self.uiauto_params['version'] = self.version
self.uiauto_params['times'] = self.times self.uiauto_params['times'] = self.times
self.uiauto_params['enable_sd_tests'] = self.enable_sd_tests self.uiauto_params['enable_sd_tests'] = self.enable_sd_tests
def setup(self, context):
if self.version == "6.0.1":
antutu_3d = context.resolver.get(File(self, "com.antutu.benchmark.full-1.apk"))
info = ApkInfo(antutu_3d)
if not context.device.is_installed(info.package):
self.device.install_apk(antutu_3d, timeout=120)
super(Antutu, self).setup(context)
def update_result(self, context): def update_result(self, context):
super(Antutu, self).update_result(context) super(Antutu, self).update_result(context)
with open(self.logcat_log) as fh: with open(self.logcat_log) as fh:
if self.version == '4.0.3': if self.version == '3.3.2':
metrics = extract_version4_metrics(fh) metrics = extract_older_version_metrics(fh)
else: else:
metrics = extract_older_version_metrics(fh) # pylint: disable=redefined-variable-type metrics = extract_metrics(fh) # pylint: disable=redefined-variable-type
for key, value in metrics.iteritems(): for key, value in metrics.iteritems():
key = key.replace(' ', '_') key = key.replace(' ', '_')
context.result.add_metric(key, value) context.result.add_metric(key, value)
@ -87,7 +96,7 @@ class Antutu(AndroidUiAutoBenchmark):
# Utility functions # Utility functions
def extract_version4_metrics(fh): def extract_metrics(fh):
metrics = OrderedDict() metrics = OrderedDict()
metric_counts = defaultdict(int) metric_counts = defaultdict(int)
for line in fh: for line in fh:

View File

@ -34,36 +34,60 @@ import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.arm.wlauto.uiauto.BaseUiAutomation; import com.arm.wlauto.uiauto.BaseUiAutomation;
public class UiAutomation extends BaseUiAutomation { public class UiAutomation extends BaseUiAutomation {
public static String TAG = "antutu"; public static String TAG = "antutu";
public static String TestButton5 = "com.antutu.ABenchMark:id/start_test_region";
public static String TestButton6 = "com.antutu.ABenchMark:id/start_test_text";
private static int initialTimeoutSeconds = 20; private static int initialTimeoutSeconds = 20;
public void runUiAutomation() throws Exception{ public void runUiAutomation() throws Exception{
Bundle parameters = getParams(); Bundle parameters = getParams();
String version = parameters.getString("version"); String version = parameters.getString("version");
boolean enableSdTests = Boolean.parseBoolean(parameters.getString("enable_sd_tests")); boolean enableSdTests = Boolean.parseBoolean(parameters.getString("enable_sd_tests"));
int times = Integer.parseInt(parameters.getString("times")); int times = Integer.parseInt(parameters.getString("times"));
if (times < 1) { if (times < 1) {
times = 1; times = 1;
} }
if (version.equals("4.0.3") || version.equals("5.3.0")){ if (version.equals("3.3.2")) { // version earlier than 4.0.3
dismissReleaseNotesDialogIfNecessary();
if(!enableSdTests){
disableSdCardTests();
}
hitStart();
waitForAndViewResults();
}
else {
int iteration = 0; int iteration = 0;
dismissNewVersionNotificationIfNecessary(); dismissNewVersionNotificationIfNecessary();
hitTestButton();
while (true) { while (true) {
if (version.equals("5.3.0")) if(version.equals("6.0.1"))
hitTestButtonVersion5(); hitTestButtonVersion5(TestButton6);
else if (version.equals("5.3.0")) {
hitTestButton();
hitTestButtonVersion5(TestButton5);
}
else if (version.equals("4.0.3")) {
hitTestButton();
hitTestButton();
}
else else
hitTestButton(); hitTestButton();
waitForVersion4Results(); if(version.equals("6.0.1"))
viewDetails(); {
extractResults(); waitForVersion6Results();
extractResults6();
}
else
{
waitForVersion4Results();
viewDetails();
extractResults();
}
iteration++; iteration++;
if (iteration >= times) { if (iteration >= times) {
@ -74,13 +98,6 @@ public class UiAutomation extends BaseUiAutomation {
dismissRateDialogIfNecessary(); dismissRateDialogIfNecessary();
testAgain(); testAgain();
} }
} else { // version earlier than 4.0.3
dismissReleaseNotesDialogIfNecessary();
if(!enableSdTests){
disableSdCardTests();
}
hitStart();
waitForAndViewResults();
} }
Bundle status = new Bundle(); Bundle status = new Bundle();
@ -98,7 +115,7 @@ public class UiAutomation extends BaseUiAutomation {
return false; return false;
} }
} }
public boolean dismissReleaseNotesDialogIfNecessary() throws Exception { public boolean dismissReleaseNotesDialogIfNecessary() throws Exception {
UiSelector selector = new UiSelector(); UiSelector selector = new UiSelector();
UiObject closeButton = new UiObject(selector.text("Close")); UiObject closeButton = new UiObject(selector.text("Close"));
@ -118,11 +135,11 @@ public class UiAutomation extends BaseUiAutomation {
// Sometimes, dismissing the dialog the first time does not work properly -- // Sometimes, dismissing the dialog the first time does not work properly --
// it starts to disappear but is then immediately re-created; so may need to // it starts to disappear but is then immediately re-created; so may need to
// dismiss it as long as keeps popping up. // dismiss it as long as keeps popping up.
while (closeButton.waitForExists(2)) { while (closeButton.waitForExists(2)) {
closeButton.click(); closeButton.click();
sleep(1); // diaglog dismissal sleep(1); // diaglog dismissal
dismissed = true; dismissed = true;
} }
return dismissed; return dismissed;
} }
@ -137,15 +154,16 @@ public class UiAutomation extends BaseUiAutomation {
/* In version 5 of antutu, the test has been changed from a button widget to a textview */ /* In version 5 of antutu, the test has been changed from a button widget to a textview */
public void hitTestButtonVersion5() throws Exception { public void hitTestButtonVersion5(String id) throws Exception {
UiSelector selector = new UiSelector(); UiSelector selector = new UiSelector();
UiObject test = new UiObject(selector.resourceId("com.antutu.ABenchMark:id/start_test_region") UiObject test = new UiObject(selector.resourceId(id)
.className("android.widget.TextView")); .className("android.widget.TextView"));
test.waitForExists(initialTimeoutSeconds); test.waitForExists(initialTimeoutSeconds);
test.click(); test.click();
sleep(1); // possible tab transtion sleep(1); // possible tab transtion
} }
public void hitTest() throws Exception { public void hitTest() throws Exception {
UiSelector selector = new UiSelector(); UiSelector selector = new UiSelector();
UiObject test = new UiObject(selector.text("Test")); UiObject test = new UiObject(selector.text("Test"));
@ -193,6 +211,17 @@ public class UiAutomation extends BaseUiAutomation {
} }
} }
public void waitForVersion6Results() throws Exception {
UiObject qrText = new UiObject(new UiSelector().className("android.widget.TextView")
.text("QRCode of result"));
for (int i = 0; i < 120; i++) {
if (qrText.exists()) {
break;
}
sleep(5);
}
}
public void viewDetails() throws Exception { public void viewDetails() throws Exception {
UiSelector selector = new UiSelector(); UiSelector selector = new UiSelector();
UiObject detailsButton = new UiObject(new UiSelector().className("android.widget.Button") UiObject detailsButton = new UiObject(new UiSelector().className("android.widget.Button")
@ -200,6 +229,30 @@ public class UiAutomation extends BaseUiAutomation {
detailsButton.clickAndWaitForNewWindow(); detailsButton.clickAndWaitForNewWindow();
} }
public void extractResults6() throws Exception {
//Overal result
UiObject result = new UiObject(new UiSelector().resourceId("com.antutu.ABenchMark:id/tv_score_name"));
if (result.exists()) {
Log.v(TAG, String.format("ANTUTU RESULT: Overall Score: %s", result.getText()));
}
// individual scores
extractSectionResults6("3d");
extractSectionResults6("ux");
extractSectionResults6("cpu");
extractSectionResults6("ram");
}
public void extractSectionResults6(String section) throws Exception {
UiSelector selector = new UiSelector();
UiObject resultLayout = new UiObject(selector.resourceId("com.antutu.ABenchMark:id/hcf_" + section));
UiObject result = resultLayout.getChild(selector.resourceId("com.antutu.ABenchMark:id/tv_score_value"));
if (result.exists()) {
Log.v(TAG, String.format("ANTUTU RESULT: %s Score: %s", section, result.getText()));
}
}
public void extractResults() throws Exception { public void extractResults() throws Exception {
extractOverallResult(); extractOverallResult();
extractSectionResults(); extractSectionResults();