mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-20 17:48:44 +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)
|
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))
|
||||||
|
Binary file not shown.
@ -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;
|
||||||
@ -17,7 +18,7 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
public class UiAutomation extends UxPerfUiAutomation {
|
public class UiAutomation extends UxPerfUiAutomation {
|
||||||
|
|
||||||
public static String TAG = "uxperf_googlephotos";
|
public static String TAG = "googlephotos";
|
||||||
|
|
||||||
public Bundle parameters;
|
public Bundle parameters;
|
||||||
private int viewTimeoutSecs = 10;
|
private int viewTimeoutSecs = 10;
|
||||||
@ -30,7 +31,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
confirmLocalFileAccess();
|
confirmLocalFileAccess();
|
||||||
dismissWelcomeView();
|
dismissWelcomeView();
|
||||||
gesturesTest();
|
gesturesTest();
|
||||||
editPhotoTest();
|
editPhotoColorTest();
|
||||||
|
cropPhotoTest();
|
||||||
|
rotatePhotoTest();
|
||||||
|
|
||||||
writeResultsToFile(timingResults, parameters.getString("output_file"));
|
writeResultsToFile(timingResults, parameters.getString("output_file"));
|
||||||
}
|
}
|
||||||
@ -44,7 +47,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
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 +56,11 @@ 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();
|
tapDisplayCentre();
|
||||||
waitObject(getStartedButton, 10);
|
waitObject(getStartedButton, viewTimeoutSecs);
|
||||||
|
|
||||||
getStartedButton.clickAndWaitForNewWindow();
|
getStartedButton.clickAndWaitForNewWindow();
|
||||||
|
|
||||||
@ -98,8 +100,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();
|
||||||
@ -109,10 +113,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
int steps = pair.getValue().steps;
|
int steps = pair.getValue().steps;
|
||||||
int percent = pair.getValue().percent;
|
int percent = pair.getValue().percent;
|
||||||
|
|
||||||
String runName = String.format(testTag + "_" + pair.getKey());
|
String runName = String.format(TAG + "_" + 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));
|
||||||
|
|
||||||
@ -123,17 +126,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;
|
||||||
@ -142,7 +145,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 =
|
||||||
@ -150,42 +153,254 @@ 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);
|
|
||||||
|
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");
|
UiObject accept = getUiObjectByDescription("Accept", "android.widget.ImageView");
|
||||||
accept.click();
|
accept.click();
|
||||||
|
|
||||||
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
UiObject save = getUiObjectByText("SAVE", "android.widget.TextView");
|
||||||
|
save.waitForExists(viewTimeout);
|
||||||
save.click();
|
save.click();
|
||||||
|
|
||||||
// Return to application home screen
|
// Return to application home screen
|
||||||
getUiDevice().pressBack();
|
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();
|
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")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user