diff --git a/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/ActionLogger.java b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/ActionLogger.java new file mode 100644 index 00000000..38e8f72a --- /dev/null +++ b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/ActionLogger.java @@ -0,0 +1,60 @@ +/* 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; + +import android.os.Bundle; +import android.util.Log; + /** + * Basic marker API for workloads to generate start and end markers for + * deliminating and timing actions. Markers are output to logcat with debug + * priority. Actions represent a series of UI interactions to time. + * + * The marker API provides a way for instruments and result processors to hook into + * per-action timings by parsing logcat logs produced per workload iteration. + * + * The marker output consists of a logcat tag 'UX_PERF' and a message. The + * message consists of a name for the action and a timestamp. The timestamp + * is separated by a single space from the name of the action. + * + * Typical usage: + * + * ActionLogger logger = ActionLogger("testTag", parameters); + * logger.start(); + * // actions to be recorded + * logger.stop(); + */ + public class ActionLogger { + + private String testTag; + private boolean enabled; + + public ActionLogger(String testTag, Bundle parameters) { + this.testTag = testTag; + this.enabled = parameters.getBoolean("markers_enabled"); + } + + public void start() { + if (enabled) { + Log.d("UX_PERF", testTag + "_start " + System.nanoTime()); + } + } + + public void stop() throws Exception { + if (enabled) { + Log.d("UX_PERF", testTag + "_end " + System.nanoTime()); + } + } + } diff --git a/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java index 8024f309..b91e7bd7 100644 --- a/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java +++ b/wa/framework/uiauto/app/src/main/java/com/arm/wa/uiauto/BaseUiAutomation.java @@ -79,6 +79,12 @@ public class BaseUiAutomation { SystemClock.sleep(second * 1000); } + //Generate a package ID + public String getPackageID(Bundle parameters) { + String packageName = parameters.getString("package_name"); + return packageName + ":id/"; + } + public boolean takeScreenshot(String name) { Bundle params = getArguments(); String png_dir = params.getString("workdir"); diff --git a/wa/framework/uiauto/uiauto.aar b/wa/framework/uiauto/uiauto.aar index 7a1a125b..01caa132 100644 Binary files a/wa/framework/uiauto/uiauto.aar and b/wa/framework/uiauto/uiauto.aar differ diff --git a/wa/workloads/vellamo/com.arm.wa.uiauto.vellamo.apk b/wa/workloads/vellamo/com.arm.wa.uiauto.vellamo.apk index 3a1341b7..58c572bd 100644 Binary files a/wa/workloads/vellamo/com.arm.wa.uiauto.vellamo.apk and b/wa/workloads/vellamo/com.arm.wa.uiauto.vellamo.apk differ diff --git a/wa/workloads/vellamo/uiauto/app/src/main/java/com/arm/wa/uiauto/vellamo/UiAutomation.java b/wa/workloads/vellamo/uiauto/app/src/main/java/com/arm/wa/uiauto/vellamo/UiAutomation.java index 19518361..048ff266 100644 --- a/wa/workloads/vellamo/uiauto/app/src/main/java/com/arm/wa/uiauto/vellamo/UiAutomation.java +++ b/wa/workloads/vellamo/uiauto/app/src/main/java/com/arm/wa/uiauto/vellamo/UiAutomation.java @@ -26,7 +26,6 @@ import android.support.test.uiautomator.UiWatcher; import android.util.Log; import com.arm.wa.uiauto.BaseUiAutomation; -import com.arm.wa.uiauto.UxPerfUiAutomation; import org.junit.Test; import org.junit.Before; @@ -42,19 +41,18 @@ public class UiAutomation extends BaseUiAutomation { public static ArrayList scores = new ArrayList(); public static Boolean wasError = false; - protected UxPerfUiAutomation uxPerf; - - Bundle parameters; - String version; - Boolean browser; - Boolean metal; - Boolean multicore; - Integer browserToUse; + protected Bundle parameters; + protected String version; + protected Boolean browser; + protected Boolean metal; + protected Boolean multicore; + protected Integer browserToUse; + protected String packageID; @Before public void initialize(){ - uxPerf = new UxPerfUiAutomation(); parameters = getParams(); + packageID = getPackageID(parameters); version = parameters.getString("version"); browser = parameters.getBoolean("browser"); metal = parameters.getBoolean("metal"); @@ -81,7 +79,7 @@ public class UiAutomation extends BaseUiAutomation { startTest(); dismissNetworkConnectionDialogIfNecessary(); dismissExplanationDialogIfNecessary(); - waitForTestCompletion(15 * 60, "com.quicinc.vellamo:id/act_ba_results_btn_no"); + waitForTestCompletion(15 * 60, packageID + "act_ba_results_btn_no"); } else { if (browser) { startBrowserTest(browserToUse, version); @@ -166,7 +164,7 @@ public class UiAutomation extends BaseUiAutomation { public void startTestV3(int run, String version) throws Exception { UiSelector selector = new UiSelector(); - UiObject thirdRunButton = mDevice.findObject(selector.resourceId("com.quicinc.vellamo:id/card_launcher_run_button").instance(2)); + UiObject thirdRunButton = mDevice.findObject(selector.resourceId(packageID + "card_launcher_run_button").instance(2)); if (!thirdRunButton.waitForExists(TimeUnit.SECONDS.toMillis(5))) { if (!thirdRunButton.exists()) { throw new UiObjectNotFoundException("Could not find three \"Run\" buttons."); @@ -174,7 +172,7 @@ public class UiAutomation extends BaseUiAutomation { } //Run benchmarks - UiObject runButton = mDevice.findObject(selector.resourceId("com.quicinc.vellamo:id/card_launcher_run_button").instance(run)); + UiObject runButton = mDevice.findObject(selector.resourceId(packageID + "card_launcher_run_button").instance(run)); if (!runButton.waitForExists(TimeUnit.SECONDS.toMillis(5))) { if (!runButton.exists()) { throw new UiObjectNotFoundException("Could not find correct \"Run\" button."); @@ -209,12 +207,12 @@ public class UiAutomation extends BaseUiAutomation { } public void proccessTest(String metric) throws Exception{ - waitForTestCompletion(15 * 60, "com.quicinc.vellamo:id/button_no"); + waitForTestCompletion(15 * 60, packageID + "button_no"); //Remove watcher mDevice.removeWatcher("stoppedWorkingDialogWatcher"); - getScore(metric, "com.quicinc.vellamo:id/card_score_score"); + getScore(metric, packageID + "card_score_score"); mDevice.pressBack(); mDevice.pressBack(); mDevice.pressBack(); @@ -279,7 +277,7 @@ public class UiAutomation extends BaseUiAutomation { public void dismissArrow() throws Exception { UiSelector selector = new UiSelector(); - UiObject cardContainer = mDevice.findObject(selector.resourceId("com.quicinc.vellamo:id/cards_container")) ; + UiObject cardContainer = mDevice.findObject(selector.resourceId(packageID + "cards_container")) ; if (!cardContainer.waitForExists(TimeUnit.SECONDS.toMillis(5))) { if (!cardContainer.exists()) { throw new UiObjectNotFoundException("Could not find vellamo main screen"); diff --git a/wa/workloads/youtube/com.arm.wa.uiauto.youtube.apk b/wa/workloads/youtube/com.arm.wa.uiauto.youtube.apk index 7bcd4c6f..4d096e87 100644 Binary files a/wa/workloads/youtube/com.arm.wa.uiauto.youtube.apk and b/wa/workloads/youtube/com.arm.wa.uiauto.youtube.apk differ diff --git a/wa/workloads/youtube/uiauto/app/src/main/java/com/arm/wa/uiauto/youtube/UiAutomation.java b/wa/workloads/youtube/uiauto/app/src/main/java/com/arm/wa/uiauto/youtube/UiAutomation.java index 4a75818e..4b1492f7 100755 --- a/wa/workloads/youtube/uiauto/app/src/main/java/com/arm/wa/uiauto/youtube/UiAutomation.java +++ b/wa/workloads/youtube/uiauto/app/src/main/java/com/arm/wa/uiauto/youtube/UiAutomation.java @@ -25,7 +25,6 @@ import android.support.test.uiautomator.UiSelector; import com.arm.wa.uiauto.BaseUiAutomation; import com.arm.wa.uiauto.ActionLogger; -import com.arm.wa.uiauto.UxPerfUiAutomation; import org.junit.Before; import org.junit.Test; @@ -46,16 +45,14 @@ public class UiAutomation extends BaseUiAutomation { public static final int VIDEO_SLEEP_SECONDS = 3; public static final int LIST_SWIPE_COUNT = 5; - protected UxPerfUiAutomation uxPerf; protected Bundle parameters; protected String packageID; @Before public void initilize() { - uxPerf = new UxPerfUiAutomation(); parameters = getParams(); - packageID = uxPerf.getPackageID(parameters); + packageID = getPackageID(parameters); } @Test