1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-20 17:48:44 +00:00

Merge pull request #7 from jimboatarm/googlephotos

Googlephotos
This commit is contained in:
jimboatarm 2016-05-09 14:38:28 +01:00
commit add4fc3c15
3 changed files with 251 additions and 50 deletions

View File

@ -13,8 +13,15 @@ class Googlephotos(AndroidUiAutoBenchmark):
description = """ description = """
A workload to perform standard productivity tasks with googlephotos. A workload to perform standard productivity tasks with googlephotos.
The workload carries out various tasks, such as browsing images, performing zooms, The workload carries out various tasks, such as browsing images, performing
postprocessing and saving a selected image to file. 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 NOTE: This workload requires four jpeg files to be placed in the
dependencies directory to run. dependencies directory to run.
@ -73,18 +80,15 @@ class Googlephotos(AndroidUiAutoBenchmark):
for line in wfh: for line in wfh:
match = regex.search(line) match = regex.search(line)
if match: if match:
context.result.add_metric((match.group('key') + "_start"), context.result.add_metric((match.group('key') + "_start"), match.group('value1'))
match.group('value1')) context.result.add_metric((match.group('key') + "_finish"), match.group('value2'))
context.result.add_metric((match.group('key') + "_finish"), context.result.add_metric((match.group('key') + "_duration"), match.group('value3'))
match.group('value2'))
context.result.add_metric((match.group('key') + "_duration"),
match.group('value3'))
def teardown(self, context): def teardown(self, context):
super(Googlephotos, self).teardown(context) super(Googlephotos, self).teardown(context)
for entry in self.device.listdir(self.device.working_directory): 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), self.device.pull_file(os.path.join(self.device.working_directory, entry),
context.output_directory) context.output_directory)
self.device.delete_file(os.path.join(self.device.working_directory, entry)) self.device.delete_file(os.path.join(self.device.working_directory, entry))

View File

@ -1,6 +1,7 @@
package com.arm.wlauto.uiauto.googlephotos; package com.arm.wlauto.uiauto.googlephotos;
import android.os.Bundle; import android.os.Bundle;
import android.graphics.Rect;
// Import the uiautomator libraries // Import the uiautomator libraries
import com.android.uiautomator.core.UiObject; import com.android.uiautomator.core.UiObject;
@ -27,24 +28,15 @@ public class UiAutomation extends UxPerfUiAutomation {
public void runUiAutomation() throws Exception { public void runUiAutomation() throws Exception {
parameters = getParams(); parameters = getParams();
confirmLocalFileAccess();
dismissWelcomeView(); dismissWelcomeView();
gesturesTest(); gesturesTest();
editPhotoTest(); editPhotoColorTest();
cropPhotoTest();
rotatePhotoTest();
writeResultsToFile(timingResults, parameters.getString("output_file")); 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 { private void dismissWelcomeView() throws Exception {
// Click through the first two pages and make sure that we don't sign // 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 sleep(5); // Pause while splash screen loads
UiObject getStartedButton = UiObject getStartedButton =
new UiObject (new UiSelector().textContains("Get started") new UiObject(new UiSelector().textContains("Get started")
.className("android.widget.Button")); .className("android.widget.Button"));
tapDisplayCentre(); waitObject(getStartedButton, viewTimeoutSecs);
waitObject(getStartedButton, 10);
getStartedButton.clickAndWaitForNewWindow(); getStartedButton.clickAndWaitForNewWindow();
@ -101,8 +92,10 @@ public class UiAutomation extends UxPerfUiAutomation {
Iterator<Entry<String, GestureTestParams>> it = testParams.entrySet().iterator(); Iterator<Entry<String, GestureTestParams>> it = testParams.entrySet().iterator();
// Select third photograph // Select first photograph
selectPhoto(2); selectPhoto(0);
String viewName = "com.google.android.apps.photos.localmedia.ui.LocalPhotosActivity";
while (it.hasNext()) { while (it.hasNext()) {
Map.Entry<String, GestureTestParams> pair = it.next(); Map.Entry<String, GestureTestParams> pair = it.next();
@ -113,9 +106,8 @@ public class UiAutomation extends UxPerfUiAutomation {
int percent = pair.getValue().percent; int percent = pair.getValue().percent;
String runName = String.format(testTag + "_" + pair.getKey()); 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 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)); UiObject view = new UiObject(new UiSelector().enabled(true));
@ -126,17 +118,17 @@ public class UiAutomation extends UxPerfUiAutomation {
startDumpsysGfxInfo(parameters); startDumpsysGfxInfo(parameters);
startDumpsysSurfaceFlinger(parameters, viewName); startDumpsysSurfaceFlinger(parameters, viewName);
Timer results = new Timer(); Timer result = new Timer();
switch (type) { switch (type) {
case UIDEVICE_SWIPE: case UIDEVICE_SWIPE:
results = uiDeviceSwipeTest(dir, steps); result = uiDeviceSwipeTest(dir, steps);
break; break;
case UIOBJECT_SWIPE: case UIOBJECT_SWIPE:
results = uiObjectSwipeTest(view, dir, steps); result = uiObjectSwipeTest(view, dir, steps);
break; break;
case PINCH: case PINCH:
results = uiObjectVertPinchTest(view, pinch, steps, percent); result = uiObjectVertPinchTest(view, pinch, steps, percent);
break; break;
default: default:
break; break;
@ -145,7 +137,7 @@ public class UiAutomation extends UxPerfUiAutomation {
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName); stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
stopDumpsysGfxInfo(parameters, gfxInfologName); stopDumpsysGfxInfo(parameters, gfxInfologName);
timingResults.put(runName, results); timingResults.put(runName, result);
} }
UiObject navigateUpButton = UiObject navigateUpButton =
@ -153,42 +145,232 @@ public class UiAutomation extends UxPerfUiAutomation {
navigateUpButton.click(); 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"; String testTag = "edit_photo";
Timer result = new Timer(); // Perform a range of swipe tests while browsing photo gallery
result.start(); 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 Iterator<Entry<String, SeekBarTestParams>> it = testParams.entrySet().iterator();
selectPhoto(0);
// Select second photograph
selectPhoto(1);
UiObject editView = getUiObjectByResourceId("com.google.android.apps.photos:id/edit", UiObject editView = getUiObjectByResourceId("com.google.android.apps.photos:id/edit",
"android.widget.ImageView"); "android.widget.ImageView");
editView.click(); editView.click();
UiObject editColor = getUiObjectByText("Colour", "android.widget.RadioButton"); // Manage potential different spelling of UI element
editColor.click(); 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", UiObject seekBar = getUiObjectByResourceId("com.google.android.apps.photos:id/cpe_strength_seek_bar",
"android.widget.SeekBar"); "android.widget.SeekBar");
seekBar.swipeLeft(10);
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView"); String viewName = "com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity";
accept.click();
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView"); while (it.hasNext()) {
save.click(); 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 String runName = String.format(testTag + "_" + pair.getKey());
getUiDevice().pressBack(); 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(); 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. // Helper to click on an individual photographs based on index in wa-working gallery.
private void selectPhoto(final int index) throws Exception { private void selectPhoto(final int index) throws Exception {
UiObject cameraHeading = new UiObject(new UiSelector().text("wa-working")); UiObject workdir = getUiObjectByText("wa-working", "android.widget.TextView");
cameraHeading.clickAndWaitForNewWindow(); workdir.clickAndWaitForNewWindow();
UiObject photo = UiObject photo =
new UiObject(new UiSelector().resourceId("com.google.android.apps.photos:id/recycler_view") new UiObject(new UiSelector().resourceId("com.google.android.apps.photos:id/recycler_view")
@ -196,4 +378,19 @@ public class UiAutomation extends UxPerfUiAutomation {
.index(index))); .index(index)));
photo.click(); 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();
}
} }