mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-14 14:48:53 +00:00
commit
add4fc3c15
@ -13,8 +13,15 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
description = """
|
||||
A workload to perform standard productivity tasks with googlephotos.
|
||||
|
||||
The workload carries out various tasks, such as browsing images, performing zooms,
|
||||
postprocessing and saving a selected image to file.
|
||||
The workload carries out various tasks, such as browsing images, performing
|
||||
zooms, post-processing and saving a selected image to file.
|
||||
|
||||
gesture test - browsing through the wa-working gallery using swipe
|
||||
gestures and performing pinch gestures for zooming
|
||||
color test - selects a photograph, increments, resets and decrements color balance
|
||||
crop test - uses image straightener facility to simultaneously rotate and
|
||||
crop a selected photograph
|
||||
rotate tests - selects a photograph and performs 90 degree rotations
|
||||
|
||||
NOTE: This workload requires four jpeg files to be placed in the
|
||||
dependencies directory to run.
|
||||
@ -73,18 +80,15 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
for line in wfh:
|
||||
match = regex.search(line)
|
||||
if match:
|
||||
context.result.add_metric((match.group('key') + "_start"),
|
||||
match.group('value1'))
|
||||
context.result.add_metric((match.group('key') + "_finish"),
|
||||
match.group('value2'))
|
||||
context.result.add_metric((match.group('key') + "_duration"),
|
||||
match.group('value3'))
|
||||
context.result.add_metric((match.group('key') + "_start"), match.group('value1'))
|
||||
context.result.add_metric((match.group('key') + "_finish"), match.group('value2'))
|
||||
context.result.add_metric((match.group('key') + "_duration"), match.group('value3'))
|
||||
|
||||
def teardown(self, context):
|
||||
super(Googlephotos, self).teardown(context)
|
||||
|
||||
for entry in self.device.listdir(self.device.working_directory):
|
||||
if entry.startswith(self.name) and entry.endswith(".log"):
|
||||
if entry.endswith(".log"):
|
||||
self.device.pull_file(os.path.join(self.device.working_directory, entry),
|
||||
context.output_directory)
|
||||
self.device.delete_file(os.path.join(self.device.working_directory, entry))
|
||||
|
Binary file not shown.
@ -1,6 +1,7 @@
|
||||
package com.arm.wlauto.uiauto.googlephotos;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.graphics.Rect;
|
||||
|
||||
// Import the uiautomator libraries
|
||||
import com.android.uiautomator.core.UiObject;
|
||||
@ -27,24 +28,15 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
public void runUiAutomation() throws Exception {
|
||||
parameters = getParams();
|
||||
|
||||
confirmLocalFileAccess();
|
||||
dismissWelcomeView();
|
||||
gesturesTest();
|
||||
editPhotoTest();
|
||||
editPhotoColorTest();
|
||||
cropPhotoTest();
|
||||
rotatePhotoTest();
|
||||
|
||||
writeResultsToFile(timingResults, parameters.getString("output_file"));
|
||||
}
|
||||
|
||||
private void confirmLocalFileAccess() throws Exception {
|
||||
// First time run requires confirmation to allow access to local files
|
||||
UiObject allowButton = new UiObject(new UiSelector().textContains("Allow")
|
||||
.className("android.widget.Button"));
|
||||
if (allowButton.waitForExists(timeout)) {
|
||||
allowButton.clickAndWaitForNewWindow(timeout);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void dismissWelcomeView() throws Exception {
|
||||
|
||||
// Click through the first two pages and make sure that we don't sign
|
||||
@ -54,11 +46,10 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
sleep(5); // Pause while splash screen loads
|
||||
|
||||
UiObject getStartedButton =
|
||||
new UiObject (new UiSelector().textContains("Get started")
|
||||
new UiObject(new UiSelector().textContains("Get started")
|
||||
.className("android.widget.Button"));
|
||||
|
||||
tapDisplayCentre();
|
||||
waitObject(getStartedButton, 10);
|
||||
waitObject(getStartedButton, viewTimeoutSecs);
|
||||
|
||||
getStartedButton.clickAndWaitForNewWindow();
|
||||
|
||||
@ -101,8 +92,10 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
|
||||
Iterator<Entry<String, GestureTestParams>> it = testParams.entrySet().iterator();
|
||||
|
||||
// Select third photograph
|
||||
selectPhoto(2);
|
||||
// Select first photograph
|
||||
selectPhoto(0);
|
||||
|
||||
String viewName = "com.google.android.apps.photos.localmedia.ui.LocalPhotosActivity";
|
||||
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, GestureTestParams> pair = it.next();
|
||||
@ -113,9 +106,8 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
int percent = pair.getValue().percent;
|
||||
|
||||
String runName = String.format(testTag + "_" + pair.getKey());
|
||||
String gfxInfologName = String.format(TAG + "_" + runName + "_gfxInfo.log");
|
||||
String gfxInfologName = String.format(runName + "_gfxInfo.log");
|
||||
String surfFlingerlogName = String.format(runName + "_surfFlinger.log");
|
||||
String viewName = new String("com.google.android.apps.photos.home.HomeActivity");
|
||||
|
||||
UiObject view = new UiObject(new UiSelector().enabled(true));
|
||||
|
||||
@ -126,17 +118,17 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
startDumpsysGfxInfo(parameters);
|
||||
startDumpsysSurfaceFlinger(parameters, viewName);
|
||||
|
||||
Timer results = new Timer();
|
||||
Timer result = new Timer();
|
||||
|
||||
switch (type) {
|
||||
case UIDEVICE_SWIPE:
|
||||
results = uiDeviceSwipeTest(dir, steps);
|
||||
result = uiDeviceSwipeTest(dir, steps);
|
||||
break;
|
||||
case UIOBJECT_SWIPE:
|
||||
results = uiObjectSwipeTest(view, dir, steps);
|
||||
result = uiObjectSwipeTest(view, dir, steps);
|
||||
break;
|
||||
case PINCH:
|
||||
results = uiObjectVertPinchTest(view, pinch, steps, percent);
|
||||
result = uiObjectVertPinchTest(view, pinch, steps, percent);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
@ -145,7 +137,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, results);
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
UiObject navigateUpButton =
|
||||
@ -153,42 +145,232 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
navigateUpButton.click();
|
||||
}
|
||||
|
||||
private void editPhotoTest() throws Exception {
|
||||
public enum Position { LEFT, RIGHT, CENTRE };
|
||||
|
||||
private class SeekBarTestParams {
|
||||
|
||||
private Position seekBarPosition;
|
||||
private int percent;
|
||||
private int steps;
|
||||
|
||||
SeekBarTestParams(final Position position, final int steps, final int percent) {
|
||||
this.seekBarPosition = position;
|
||||
this.steps = steps;
|
||||
this.percent = percent;
|
||||
}
|
||||
}
|
||||
|
||||
private void editPhotoColorTest() throws Exception {
|
||||
String testTag = "edit_photo";
|
||||
|
||||
Timer result = new Timer();
|
||||
result.start();
|
||||
// Perform a range of swipe tests while browsing photo gallery
|
||||
LinkedHashMap<String, SeekBarTestParams> testParams = new LinkedHashMap<String, SeekBarTestParams>();
|
||||
testParams.put("increment_color", new SeekBarTestParams(Position.RIGHT, 10, 20));
|
||||
testParams.put("reset_color", new SeekBarTestParams(Position.CENTRE, 0, 0));
|
||||
testParams.put("decrement_color", new SeekBarTestParams(Position.LEFT, 10, 20));
|
||||
|
||||
// Select first photograph
|
||||
selectPhoto(0);
|
||||
Iterator<Entry<String, SeekBarTestParams>> it = testParams.entrySet().iterator();
|
||||
|
||||
// Select second photograph
|
||||
selectPhoto(1);
|
||||
UiObject editView = getUiObjectByResourceId("com.google.android.apps.photos:id/edit",
|
||||
"android.widget.ImageView");
|
||||
editView.click();
|
||||
|
||||
UiObject editColor = getUiObjectByText("Colour", "android.widget.RadioButton");
|
||||
editColor.click();
|
||||
// Manage potential different spelling of UI element
|
||||
UiObject editColor = new UiObject(new UiSelector().text("Color"));
|
||||
UiObject editColour = new UiObject(new UiSelector().text("Colour"));
|
||||
|
||||
if (editColor.exists()) {
|
||||
editColor.click();
|
||||
} else if (editColour.exists()) {
|
||||
editColour.click();
|
||||
} else {
|
||||
throw new UiObjectNotFoundException(String.format("Could not find \"%s\" \"%s\"",
|
||||
"Color/Colour", "android.widget.RadioButton"));
|
||||
}
|
||||
|
||||
UiObject seekBar = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_strength_seek_bar",
|
||||
"android.widget.SeekBar");
|
||||
seekBar.swipeLeft(10);
|
||||
|
||||
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||
accept.click();
|
||||
String viewName = "com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity";
|
||||
|
||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||
save.click();
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, SeekBarTestParams> pair = it.next();
|
||||
Position pos = pair.getValue().seekBarPosition;
|
||||
int steps = pair.getValue().steps;
|
||||
int percent = pair.getValue().percent;
|
||||
|
||||
// Return to application home screen
|
||||
getUiDevice().pressBack();
|
||||
String runName = String.format(testTag + "_" + pair.getKey());
|
||||
String gfxInfologName = String.format(runName + "_gfxInfo.log");
|
||||
String surfFlingerlogName = String.format(runName + "_surfFlinger.log");
|
||||
|
||||
startDumpsysGfxInfo(parameters);
|
||||
startDumpsysSurfaceFlinger(parameters, viewName);
|
||||
|
||||
Timer result = new Timer();
|
||||
result = seekBarTest(seekBar, pos, steps);
|
||||
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
saveAndReturn();
|
||||
}
|
||||
|
||||
private void cropPhotoTest() throws Exception {
|
||||
String testTag = "crop_photo";
|
||||
|
||||
// To improve travel accuracy perform the slide bar operation slowly
|
||||
final int steps = 500;
|
||||
|
||||
// Perform a range of swipe tests while browsing photo gallery
|
||||
LinkedHashMap<String, Position> testParams = new LinkedHashMap<String, Position>();
|
||||
testParams.put("tilt_positive", Position.LEFT);
|
||||
testParams.put("tilt_reset", Position.RIGHT);
|
||||
testParams.put("tilt_negative", Position.RIGHT);
|
||||
|
||||
Iterator<Entry<String, Position>> it = testParams.entrySet().iterator();
|
||||
|
||||
// Select third photograph
|
||||
selectPhoto(2);
|
||||
UiObject editView = getUiObjectByResourceId("com.google.android.apps.photos:id/edit",
|
||||
"android.widget.ImageView");
|
||||
editView.click();
|
||||
|
||||
UiObject cropTool = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_crop_tool",
|
||||
"android.widget.ImageView");
|
||||
cropTool.click();
|
||||
|
||||
UiObject straightenSlider = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_straighten_slider",
|
||||
"android.view.View");
|
||||
|
||||
String viewName = "com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity";
|
||||
|
||||
while (it.hasNext()) {
|
||||
Map.Entry<String, Position> pair = it.next();
|
||||
Position pos = pair.getValue();
|
||||
|
||||
String runName = String.format(testTag + "_" + pair.getKey());
|
||||
String gfxInfologName = String.format(runName + "_gfxInfo.log");
|
||||
String surfFlingerlogName = String.format(runName + "_surfFlinger.log");
|
||||
|
||||
startDumpsysGfxInfo(parameters);
|
||||
startDumpsysSurfaceFlinger(parameters, viewName);
|
||||
|
||||
Timer result = new Timer();
|
||||
result = slideBarTest(straightenSlider , pos, steps);
|
||||
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
saveAndReturn();
|
||||
}
|
||||
|
||||
private void rotatePhotoTest() throws Exception {
|
||||
String testTag = "rotate_photo";
|
||||
|
||||
String[] subTests = {"anticlockwise_90", "anticlockwise_180", "anticlockwise_270"};
|
||||
|
||||
// Select fourth photograph
|
||||
selectPhoto(3);
|
||||
UiObject editView = getUiObjectByResourceId("com.google.android.apps.photos:id/edit",
|
||||
"android.widget.ImageView");
|
||||
editView.click();
|
||||
|
||||
UiObject cropTool = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_crop_tool",
|
||||
"android.widget.ImageView");
|
||||
cropTool.click();
|
||||
|
||||
UiObject rotate = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_rotate_90",
|
||||
"android.widget.ImageView");
|
||||
|
||||
String viewName = "com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity";
|
||||
|
||||
for (String subTest : subTests) {
|
||||
String runName = String.format(testTag + "_" + subTest);
|
||||
String gfxInfologName = String.format(runName + "_gfxInfo.log");
|
||||
String surfFlingerlogName = String.format(runName + "_surfFlinger.log");
|
||||
|
||||
startDumpsysGfxInfo(parameters);
|
||||
startDumpsysSurfaceFlinger(parameters, viewName);
|
||||
|
||||
Timer result = new Timer();
|
||||
result.start();
|
||||
rotate.click();
|
||||
result.end();
|
||||
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
saveAndReturn();
|
||||
}
|
||||
|
||||
// Helper to slide the seekbar during photo edit.
|
||||
private Timer seekBarTest(final UiObject view, final Position pos, final int steps) throws Exception {
|
||||
final int SWIPE_MARGIN_LIMIT = 5;
|
||||
Rect rect = view.getVisibleBounds();
|
||||
|
||||
Timer result = new Timer();
|
||||
result.start();
|
||||
|
||||
switch (pos) {
|
||||
case LEFT:
|
||||
getUiDevice().click(rect.left + SWIPE_MARGIN_LIMIT, rect.centerY());
|
||||
break;
|
||||
case RIGHT:
|
||||
getUiDevice().click(rect.right - SWIPE_MARGIN_LIMIT, rect.centerY());
|
||||
break;
|
||||
case CENTRE:
|
||||
view.click();
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
result.end();
|
||||
timingResults.put(testTag, result);
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helper to slide the slidebar during photo edit.
|
||||
private Timer slideBarTest(final UiObject view, final Position pos, final int steps) throws Exception {
|
||||
final int SWIPE_MARGIN_LIMIT = 5;
|
||||
Rect rect = view.getBounds();
|
||||
|
||||
Timer result = new Timer();
|
||||
result.start();
|
||||
|
||||
switch (pos) {
|
||||
case LEFT:
|
||||
getUiDevice().drag(rect.left + SWIPE_MARGIN_LIMIT, rect.centerY(),
|
||||
rect.left + rect.width() / 4, rect.centerY(),
|
||||
steps);
|
||||
break;
|
||||
case RIGHT:
|
||||
getUiDevice().drag(rect.right - SWIPE_MARGIN_LIMIT, rect.centerY(),
|
||||
rect.right - rect.width() / 4, rect.centerY(),
|
||||
steps);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
result.end();
|
||||
return result;
|
||||
}
|
||||
|
||||
// Helper to click on an individual photographs based on index in wa-working gallery.
|
||||
private void selectPhoto(final int index) throws Exception {
|
||||
UiObject cameraHeading = new UiObject(new UiSelector().text("wa-working"));
|
||||
cameraHeading.clickAndWaitForNewWindow();
|
||||
UiObject workdir = getUiObjectByText("wa-working", "android.widget.TextView");
|
||||
workdir.clickAndWaitForNewWindow();
|
||||
|
||||
UiObject photo =
|
||||
new UiObject(new UiSelector().resourceId("com.google.android.apps.photos:id/recycler_view")
|
||||
@ -196,4 +378,19 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
.index(index)));
|
||||
photo.click();
|
||||
}
|
||||
|
||||
// Helper that accepts, saves and navigates back to application home screen after an edit operation
|
||||
private void saveAndReturn() throws Exception {
|
||||
|
||||
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||
accept.click();
|
||||
|
||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||
save.waitForExists(viewTimeout);
|
||||
save.click();
|
||||
|
||||
UiObject navigateUpButton =
|
||||
getUiObjectByDescription("Navigate Up", "android.widget.ImageButton");
|
||||
navigateUpButton.click();
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user