mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-10-31 07:04:17 +00:00 
			
		
		
		
	PCMark: Porting to WA3
This commit is contained in:
		
							
								
								
									
										41
									
								
								wa/workloads/pcmark/uiauto/app/build.gradle
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										41
									
								
								wa/workloads/pcmark/uiauto/app/build.gradle
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,41 @@ | ||||
| apply plugin: 'com.android.application' | ||||
|  | ||||
| def packageName = "com.arm.wa.uiauto.pcmark" | ||||
|  | ||||
| android { | ||||
|     compileSdkVersion 25 | ||||
|     buildToolsVersion "25.0.3" | ||||
|     defaultConfig { | ||||
|         applicationId "${packageName}" | ||||
|         minSdkVersion 18 | ||||
|         targetSdkVersion 25 | ||||
|         versionCode 1 | ||||
|         versionName "1.0" | ||||
|         testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" | ||||
|     } | ||||
|     buildTypes { | ||||
|         release { | ||||
|             minifyEnabled false | ||||
|             proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' | ||||
|         } | ||||
|         applicationVariants.all { variant -> | ||||
|             variant.outputs.each { output -> | ||||
|                 output.outputFile = file("$project.buildDir/apk/${packageName}.apk") | ||||
|             } | ||||
|         } | ||||
|     } | ||||
| } | ||||
|  | ||||
| dependencies { | ||||
|     compile fileTree(dir: 'libs', include: ['*.jar']) | ||||
|     compile 'com.android.support.test:runner:0.5' | ||||
|     compile 'com.android.support.test:rules:0.5' | ||||
|     compile 'com.android.support.test.uiautomator:uiautomator-v18:2.1.2' | ||||
|     compile(name: 'uiauto', ext:'aar') | ||||
| } | ||||
|  | ||||
| repositories { | ||||
|     flatDir { | ||||
|         dirs 'libs' | ||||
|     } | ||||
| } | ||||
							
								
								
									
										13
									
								
								wa/workloads/pcmark/uiauto/app/src/main/AndroidManifest.xml
									
									
									
									
									
										Executable file
									
								
							
							
						
						
									
										13
									
								
								wa/workloads/pcmark/uiauto/app/src/main/AndroidManifest.xml
									
									
									
									
									
										Executable file
									
								
							| @@ -0,0 +1,13 @@ | ||||
| <?xml version="1.0" encoding="utf-8"?> | ||||
| <manifest xmlns:android="http://schemas.android.com/apk/res/android" | ||||
|     package="com.arm.wa.uiauto.pcmark" | ||||
|     android:versionCode="1" | ||||
|     android:versionName="1.0"> | ||||
|  | ||||
|  | ||||
|     <instrumentation | ||||
|         android:name="android.support.test.runner.AndroidJUnitRunner" | ||||
|         android:targetPackage="${applicationId}"/> | ||||
|  | ||||
| </manifest> | ||||
|  | ||||
| @@ -0,0 +1,143 @@ | ||||
| /*    Copyright 2014-2016 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.pcmark; | ||||
|  | ||||
| import android.os.Bundle; | ||||
| import android.support.test.runner.AndroidJUnit4; | ||||
| import android.support.test.uiautomator.UiObject; | ||||
| import android.support.test.uiautomator.UiObjectNotFoundException; | ||||
| import android.support.test.uiautomator.UiSelector; | ||||
|  | ||||
| import com.arm.wa.uiauto.BaseUiAutomation; | ||||
| import com.arm.wa.uiauto.ActionLogger; | ||||
| import android.util.Log; | ||||
|  | ||||
| import org.junit.Before; | ||||
| import org.junit.Test; | ||||
| import org.junit.runner.RunWith; | ||||
|  | ||||
| import java.util.concurrent.TimeUnit; | ||||
|  | ||||
| @RunWith(AndroidJUnit4.class) | ||||
| public class UiAutomation extends BaseUiAutomation { | ||||
|  | ||||
|     private int networkTimeoutSecs = 30; | ||||
|     private long networkTimeout =  TimeUnit.SECONDS.toMillis(networkTimeoutSecs); | ||||
|     public static String TAG = "UXPERF"; | ||||
|  | ||||
|     @Before | ||||
|     public void initialize(){ | ||||
|         initialize_instrumentation(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void setup() throws Exception{ | ||||
|         setScreenOrientation(ScreenOrientation.NATURAL); | ||||
|         loadBenchmarks(); | ||||
|         installBenchmark(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void runWorkload() throws Exception { | ||||
|         runBenchmark(); | ||||
|     } | ||||
|  | ||||
|     @Test | ||||
|     public void teardown() throws Exception{ | ||||
|         unsetScreenOrientation(); | ||||
|     } | ||||
|  | ||||
|     //Swipe to benchmarks and back to initialise the app correctly | ||||
|     private void loadBenchmarks() throws Exception { | ||||
|         UiObject title =  | ||||
|             mDevice.findObject(new UiSelector().text("PCMARK")); | ||||
|         title.waitForExists(300000); | ||||
|         if (title.exists()){ | ||||
|             title.click(); | ||||
|             UiObject benchPage = getUiObjectByText("BENCHMARKS"); | ||||
|             benchPage.waitForExists(60000); | ||||
|             benchPage.click(); | ||||
|             benchPage.click(); | ||||
|             UiObject pcmark = getUiObjectByText("PCMARK"); | ||||
|             pcmark.waitForExists(60000); | ||||
|             pcmark.click(); | ||||
|         } else { | ||||
|             throw new UiObjectNotFoundException("Application has not loaded within the given time"); | ||||
|         } | ||||
|     } | ||||
|  | ||||
|     //Install the Work 2.0 Performance Benchmark | ||||
|     private void installBenchmark() throws Exception { | ||||
|         UiObject benchmark =  | ||||
|             mDevice.findObject(new UiSelector().descriptionContains("INSTALL(")); | ||||
|         if (benchmark.exists()) { | ||||
|             benchmark.click(); | ||||
|         } else { | ||||
|             UiObject benchmarktext =  | ||||
|                 mDevice.findObject(new UiSelector().textContains("INSTALL(")); | ||||
|             benchmarktext.click(); | ||||
|         } | ||||
|             UiObject install =  | ||||
|                 mDevice.findObject(new UiSelector().description("INSTALL") | ||||
|                     .className("android.view.View")); | ||||
|             if (install.exists()) { | ||||
|                 install.click(); | ||||
|             } else { | ||||
|                 UiObject installtext =  | ||||
|                     mDevice.findObject(new UiSelector().text("INSTALL") | ||||
|                         .className("android.view.View")); | ||||
|                 installtext.click();; | ||||
|                 } | ||||
|                 UiObject installed = | ||||
|                     mDevice.findObject(new UiSelector().description("RUN") | ||||
|                         .className("android.view.View")); | ||||
|                 installed.waitForExists(360000); | ||||
|                 if (!installed.exists()){ | ||||
|                     UiObject installedtext = | ||||
|                         mDevice.findObject(new UiSelector().text("RUN") | ||||
|                             .className("android.view.View")); | ||||
|                     installedtext.waitForExists(1000); | ||||
|                 } | ||||
|     } | ||||
|      | ||||
|     //Execute the Work 2.0 Performance Benchmark - wait up to ten minutes for this to complete | ||||
|     private void runBenchmark() throws Exception { | ||||
|         UiObject run = | ||||
|             mDevice.findObject(new UiSelector().resourceId("CONTROL_PCMA_WORK_V2_DEFAULT") | ||||
|                                                .className("android.view.View") | ||||
|                                                .childSelector(new UiSelector().index(1) | ||||
|                                                .className("android.view.View"))); | ||||
|         if (run.exists()) { | ||||
|             run.click(); | ||||
|         } else { | ||||
|             UiObject runtext =  | ||||
|                 mDevice.findObject(new UiSelector().text("RUN")); | ||||
|                 if (runtext.exists()) { | ||||
|                     runtext.click(); | ||||
|                 } else { | ||||
|                     UiObject rundesc =  | ||||
|                         mDevice.findObject(new UiSelector().description("RUN")); | ||||
|                     rundesc.click(); | ||||
|                 } | ||||
|         } | ||||
|         UiObject score =  | ||||
|             mDevice.findObject(new UiSelector().text("SCORE DETAILS") | ||||
|                 .className("android.widget.TextView")); | ||||
|         if (!score.waitForExists(3600000)){ | ||||
|             throw new UiObjectNotFoundException("Workload has not completed within the given time"); | ||||
|         } | ||||
|     } | ||||
| } | ||||
		Reference in New Issue
	
	Block a user