mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-14 14:48:53 +00:00
Extend Googlephotos workload
Extend workload to add crop and rotation testing to UI automation. Add SurfaceFlinger dumps whilst performing editing operations.
This commit is contained in:
parent
9c45c42f69
commit
16551a5d3f
@ -84,7 +84,7 @@ class Googlephotos(AndroidUiAutoBenchmark):
|
||||
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;
|
||||
@ -17,7 +18,7 @@ import java.util.Map.Entry;
|
||||
|
||||
public class UiAutomation extends UxPerfUiAutomation {
|
||||
|
||||
public static String TAG = "uxperf_googlephotos";
|
||||
public static String TAG = "googlephotos";
|
||||
|
||||
public Bundle parameters;
|
||||
private int viewTimeoutSecs = 10;
|
||||
@ -30,7 +31,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
confirmLocalFileAccess();
|
||||
dismissWelcomeView();
|
||||
gesturesTest();
|
||||
editPhotoTest();
|
||||
editPhotoColorTest();
|
||||
cropPhotoTest();
|
||||
rotatePhotoTest();
|
||||
|
||||
writeResultsToFile(timingResults, parameters.getString("output_file"));
|
||||
}
|
||||
@ -44,7 +47,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void dismissWelcomeView() throws Exception {
|
||||
|
||||
// Click through the first two pages and make sure that we don't sign
|
||||
@ -54,11 +56,11 @@ 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();
|
||||
|
||||
@ -98,8 +100,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();
|
||||
@ -109,10 +113,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
int steps = pair.getValue().steps;
|
||||
int percent = pair.getValue().percent;
|
||||
|
||||
String runName = String.format(testTag + "_" + pair.getKey());
|
||||
String gfxInfologName = String.format(TAG + "_" + runName + "_gfxInfo.log");
|
||||
String runName = String.format(TAG + "_" + testTag + "_" + pair.getKey());
|
||||
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));
|
||||
|
||||
@ -123,17 +126,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;
|
||||
@ -142,7 +145,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, results);
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
UiObject navigateUpButton =
|
||||
@ -150,42 +153,254 @@ 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);
|
||||
|
||||
String viewName = "com.google.android.apps.consumerphotoeditor.fragments.ConsumerPhotoEditorActivity";
|
||||
|
||||
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;
|
||||
|
||||
String runName = String.format(TAG + "_" + 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);
|
||||
}
|
||||
|
||||
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||
accept.click();
|
||||
|
||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||
save.waitForExists(viewTimeout);
|
||||
save.click();
|
||||
|
||||
// Return to application home screen
|
||||
getUiDevice().pressBack();
|
||||
}
|
||||
|
||||
private void cropPhotoTest() throws Exception {
|
||||
String testTag = "crop_photo";
|
||||
|
||||
// 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(TAG + "_" + testTag + "_" + pair.getKey());
|
||||
String gfxInfologName = String.format(runName + "_" + runName + "_gfxInfo.log");
|
||||
String surfFlingerlogName = String.format(runName + "_surfFlinger.log");
|
||||
|
||||
startDumpsysGfxInfo(parameters);
|
||||
startDumpsysSurfaceFlinger(parameters, viewName);
|
||||
|
||||
Timer result = new Timer();
|
||||
result = slideBarTest(straightenSlider , pos, 100);
|
||||
|
||||
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
|
||||
stopDumpsysGfxInfo(parameters, gfxInfologName);
|
||||
|
||||
timingResults.put(runName, result);
|
||||
}
|
||||
|
||||
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||
accept.click();
|
||||
|
||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||
save.waitForExists(viewTimeout);
|
||||
save.click();
|
||||
|
||||
// Return to application home screen
|
||||
getUiDevice().pressBack();
|
||||
}
|
||||
|
||||
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(TAG + "_" + 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);
|
||||
}
|
||||
|
||||
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||
accept.click();
|
||||
|
||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||
save.waitForExists(viewTimeout);
|
||||
save.click();
|
||||
|
||||
// Return to application home screen
|
||||
getUiDevice().pressBack();
|
||||
}
|
||||
|
||||
// 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")
|
||||
|
Loading…
x
Reference in New Issue
Block a user