diff --git a/wa/workloads/antutu/__init__.py b/wa/workloads/antutu/__init__.py index 3a01a868..eb271918 100755 --- a/wa/workloads/antutu/__init__.py +++ b/wa/workloads/antutu/__init__.py @@ -14,25 +14,40 @@ # import re -from wa import ApkUiautoWorkload, WorkloadError +from wa import ApkUiautoWorkload, WorkloadError, Parameter class Antutu(ApkUiautoWorkload): name = 'antutu' package_names = ['com.antutu.ABenchMark'] - regex_matches = [re.compile(r'CPU Maths Score (.+)'), - re.compile(r'CPU Common Score (.+)'), - re.compile(r'CPU Multi Score (.+)'), - re.compile(r'GPU Marooned Score (.+)'), - re.compile(r'GPU Coastline Score (.+)'), - re.compile(r'GPU Refinery Score (.+)'), - re.compile(r'Data Security Score (.+)'), - re.compile(r'Data Processing Score (.+)'), - re.compile(r'Image Processing Score (.+)'), - re.compile(r'User Experience Score (.+)'), - re.compile(r'RAM Score (.+)'), - re.compile(r'ROM Score (.+)')] + regex_matches_v7 = [re.compile(r'CPU Maths Score (.+)'), + re.compile(r'CPU Common Score (.+)'), + re.compile(r'CPU Multi Score (.+)'), + re.compile(r'GPU Marooned Score (.+)'), + re.compile(r'GPU Coastline Score (.+)'), + re.compile(r'GPU Refinery Score (.+)'), + re.compile(r'Data Security Score (.+)'), + re.compile(r'Data Processing Score (.+)'), + re.compile(r'Image Processing Score (.+)'), + re.compile(r'User Experience Score (.+)'), + re.compile(r'RAM Score (.+)'), + re.compile(r'ROM Score (.+)')] + regex_matches_v8 = [re.compile(r'CPU Mathematical Operations Score (.+)'), + re.compile(r'CPU Common Algorithms Score (.+)'), + re.compile(r'CPU Multi-Core Score (.+)'), + re.compile(r'GPU Terracotta Score (.+)'), + re.compile(r'GPU Coastline Score (.+)'), + re.compile(r'GPU Refinery Score (.+)'), + re.compile(r'Data Security Score (.+)'), + re.compile(r'Data Processing Score (.+)'), + re.compile(r'Image Processing Score (.+)'), + re.compile(r'User Experience Score (.+)'), + re.compile(r'RAM Access Score (.+)'), + re.compile(r'ROM APP IO Score (.+)'), + re.compile(r'ROM Sequential Read Score (.+)'), + re.compile(r'ROM Sequential Write Score (.+)'), + re.compile(r'ROM Random Access Score (.+)')] description = ''' Executes Antutu 3D, UX, CPU and Memory tests @@ -40,16 +55,31 @@ class Antutu(ApkUiautoWorkload): 1. Open Antutu application 2. Execute Antutu benchmark - Known working APK version: 7.0.4 + Known working APK version: 8.0.4 ''' - def update_output(self, context): - super(Antutu, self).update_output(context) - expected_results = len(self.regex_matches) + supported_versions = ['7.0.4', '7.2.0', '8.0.4', '8.1.9'] + + parameters = [ + Parameter('version', kind=str, allowed_values=supported_versions, override=True, + description=( + '''Specify the version of Antutu to be run. + If not specified, the latest available version will be used. + ''') + ) + ] + + def setup(self, context): + self.gui.uiauto_params['version'] = self.version + super(Antutu, self).setup(context) + + def extract_scores(self, context, regex_version): + #pylint: disable=no-self-use + expected_results = len(regex_version) logcat_file = context.get_artifact_path('logcat') with open(logcat_file) as fh: for line in fh: - for regex in self.regex_matches: + for regex in regex_version: match = regex.search(line) if match: try: @@ -61,4 +91,11 @@ class Antutu(ApkUiautoWorkload): expected_results -= 1 if expected_results > 0: msg = "The Antutu workload has failed. Expected {} scores, Detected {} scores." - raise WorkloadError(msg.format(len(self.regex_matches), expected_results)) + raise WorkloadError(msg.format(len(regex_version), expected_results)) + + def update_output(self, context): + super(Antutu, self).update_output(context) + if self.version.startswith('8'): + self.extract_scores(context, self.regex_matches_v8) + if self.version.startswith('7'): + self.extract_scores(context, self.regex_matches_v7) diff --git a/wa/workloads/antutu/com.arm.wa.uiauto.antutu.apk b/wa/workloads/antutu/com.arm.wa.uiauto.antutu.apk index d39f9850..ae4ef353 100644 Binary files a/wa/workloads/antutu/com.arm.wa.uiauto.antutu.apk and b/wa/workloads/antutu/com.arm.wa.uiauto.antutu.apk differ diff --git a/wa/workloads/antutu/uiauto/app/src/main/java/com/arm/wa/uiauto/antutu/UiAutomation.java b/wa/workloads/antutu/uiauto/app/src/main/java/com/arm/wa/uiauto/antutu/UiAutomation.java index 40a3ae0b..a6ce2a9a 100755 --- a/wa/workloads/antutu/uiauto/app/src/main/java/com/arm/wa/uiauto/antutu/UiAutomation.java +++ b/wa/workloads/antutu/uiauto/app/src/main/java/com/arm/wa/uiauto/antutu/UiAutomation.java @@ -27,6 +27,7 @@ import android.util.Log; import com.arm.wa.uiauto.BaseUiAutomation; +import org.junit.Before; import org.junit.Test; import org.junit.runner.RunWith; @@ -41,6 +42,14 @@ public class UiAutomation extends BaseUiAutomation { 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; + protected Bundle parameters; + protected String version; + + @Before + public void initialize(){ + parameters = getParams(); + version = parameters.getString("version"); + } @Test public void setup() throws Exception { @@ -56,7 +65,11 @@ public class UiAutomation extends BaseUiAutomation { @Test public void extractResults() throws Exception{ - getScores(); + if (version.startsWith("8")){ + getScoresv8(); + } else { + getScoresv7(); + } } public void hitTest() throws Exception { @@ -67,6 +80,13 @@ public class UiAutomation extends BaseUiAutomation { } public void clearPopups() throws Exception { + UiObject agreement = + mDevice.findObject(new UiSelector().textContains("NEXT")); + agreement.waitForExists(5000); + if (agreement.exists()){ + agreement.click(); + } + UiObject cancel = mDevice.findObject(new UiSelector().textContains("CANCEL")); cancel.waitForExists(5000); @@ -81,7 +101,7 @@ public class UiAutomation extends BaseUiAutomation { totalScore.waitForExists(600000); } - public void getScores() throws Exception { + public void getScoresv7() throws Exception { //Expand, Extract and Close CPU sub scores UiObject cpuscores = mDevice.findObject(new UiSelector().text("CPU")); @@ -143,4 +163,114 @@ public class UiAutomation extends BaseUiAutomation { memscores.click(); } + public void getScoresv8() throws Exception { + UiScrollable list = new UiScrollable(new UiSelector().scrollable(true)); + + //Expand, Extract and Close CPU sub scores + UiObject cpuscores = + mDevice.findObject(new UiSelector().resourceId("com.antutu.ABenchMark:id/result_details_recyclerView")) + .getChild(new UiSelector().index(2)) + .getChild(new UiSelector().index(4)); + cpuscores.click(); + UiObject cpumaths = + mDevice.findObject(new UiSelector().text("CPU Mathematical Operations").fromParent(new UiSelector().index(1))); + UiObject cpucommon = + mDevice.findObject(new UiSelector().text("CPU Common Algorithms").fromParent(new UiSelector().index(1))); + UiObject cpumulti = + mDevice.findObject(new UiSelector().text("CPU Multi-Core").fromParent(new UiSelector().index(1))); + Log.d(TAG, "CPU Mathematical Operations Score " + cpumaths.getText()); + Log.d(TAG, "CPU Common Algorithms Score " + cpucommon.getText()); + Log.d(TAG, "CPU Multi-Core Score " + cpumulti.getText()); + cpuscores.click(); + + //Expand, Extract and Close GPU sub scores + UiObject gpuscores = + mDevice.findObject(new UiSelector().resourceId("com.antutu.ABenchMark:id/result_details_recyclerView")) + .getChild(new UiSelector().index(3)) + .getChild(new UiSelector().index(4)); + gpuscores.click(); + UiObject gputerracotta = + mDevice.findObject(new UiSelector().text("Terracotta - Vulkan").fromParent(new UiSelector().index(1))); + UiObject gpucoast = + mDevice.findObject(new UiSelector().text("Coastline - Vulkan").fromParent(new UiSelector().index(1))); + UiObject gpurefinery = + mDevice.findObject(new UiSelector().text("Refinery - OpenGL ES3.1+AEP").fromParent(new UiSelector().index(1))); + Log.d(TAG, "GPU Terracotta Score " + gputerracotta.getText()); + Log.d(TAG, "GPU Coastline Score " + gpucoast.getText()); + Log.d(TAG, "GPU Refinery Score " + gpurefinery.getText()); + gpuscores.click(); + + //Expand, Extract and Close UX sub scores + UiObject uxscores = + mDevice.findObject(new UiSelector().resourceId("com.antutu.ABenchMark:id/result_details_recyclerView")) + .getChild(new UiSelector().index(5)) + .getChild(new UiSelector().index(4)); + uxscores.click(); + UiObject security = + mDevice.findObject(new UiSelector().text("Data Security").fromParent(new UiSelector().index(1))); + UiObject dataprocessing = + mDevice.findObject(new UiSelector().text("Data Processing").fromParent(new UiSelector().index(1))); + UiObject imageprocessing = + mDevice.findObject(new UiSelector().text("Image Processing").fromParent(new UiSelector().index(1))); + UiObject uxscore = + mDevice.findObject(new UiSelector().text("User Experience").fromParent(new UiSelector().index(1))); + if (!security.exists() && list.waitForExists(60)) { + list.scrollIntoView(security); + } + Log.d(TAG, "Data Security Score " + security.getText()); + if (!dataprocessing.exists() && list.waitForExists(60)) { + list.scrollIntoView(dataprocessing); + } + Log.d(TAG, "Data Processing Score " + dataprocessing.getText()); + if (!imageprocessing.exists() && list.waitForExists(60)) { + list.scrollIntoView(imageprocessing); + } + Log.d(TAG, "Image Processing Score " + imageprocessing.getText()); + if (!uxscore.exists() && list.waitForExists(60)) { + list.scrollIntoView(uxscore); + } + Log.d(TAG, "User Experience Score " + uxscore.getText()); + list.scrollToBeginning(10); + uxscores.click(); + + //Expand, Extract and Close MEM sub scores + UiObject memscores = + mDevice.findObject(new UiSelector().resourceId("com.antutu.ABenchMark:id/result_details_recyclerView")) + .getChild(new UiSelector().index(4)) + .getChild(new UiSelector().index(4)); + memscores.click(); + UiObject ramaccess = + mDevice.findObject(new UiSelector().text("RAM Access").fromParent(new UiSelector().index(1))); + UiObject romapp = + mDevice.findObject(new UiSelector().text("ROM APP IO").fromParent(new UiSelector().index(1))); + UiObject romread = + mDevice.findObject(new UiSelector().text("ROM Sequential Read").fromParent(new UiSelector().index(1))); + UiObject romwrite = + mDevice.findObject(new UiSelector().text("ROM Sequential Write").fromParent(new UiSelector().index(1))); + UiObject romaccess = + mDevice.findObject(new UiSelector().text("ROM Random Access").fromParent(new UiSelector().index(1))); + if (!ramaccess.exists() && list.waitForExists(60)) { + list.scrollIntoView(ramaccess); + } + Log.d(TAG, "RAM Access Score " + ramaccess.getText()); + if (!romapp.exists() && list.waitForExists(60)) { + list.scrollIntoView(romapp); + } + Log.d(TAG, "ROM APP IO Score " + romapp.getText()); + if (!romread.exists() && list.waitForExists(60)) { + list.scrollIntoView(romread); + } + Log.d(TAG, "ROM Sequential Read Score " + romread.getText()); + if (!romwrite.exists() && list.waitForExists(60)) { + list.scrollIntoView(romwrite); + } + Log.d(TAG, "ROM Sequential Write Score " + romwrite.getText()); + if (!romaccess.exists() && list.waitForExists(60)) { + list.scrollIntoView(romaccess); + } + Log.d(TAG, "ROM Random Access Score " + romaccess.getText()); + list.scrollToBeginning(10); + memscores.click(); + } + }