mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-04-14 06:40:52 +01:00
Merge pull request #252 from jimboatarm/googlephotos-cropspeedchange
GooglePhotos: Change step value for crop operation to speed up workload
This commit is contained in:
commit
0232341445
@ -15,7 +15,7 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
|
|
||||||
from wlauto import AndroidUxPerfWorkload, Parameter, File
|
from wlauto import AndroidUxPerfWorkload, Parameter
|
||||||
from wlauto.exceptions import ValidationError
|
from wlauto.exceptions import ValidationError
|
||||||
from wlauto.utils.types import list_of_strings
|
from wlauto.utils.types import list_of_strings
|
||||||
from wlauto.utils.misc import unique
|
from wlauto.utils.misc import unique
|
||||||
@ -32,15 +32,14 @@ class Googlephotos(AndroidUxPerfWorkload):
|
|||||||
package + '/com.google.android.apps.photos.localmedia.ui.LocalPhotosActivity',
|
package + '/com.google.android.apps.photos.localmedia.ui.LocalPhotosActivity',
|
||||||
package + '/com.google.android.apps.photos.onboarding.AccountPickerActivity',
|
package + '/com.google.android.apps.photos.onboarding.AccountPickerActivity',
|
||||||
package + '/com.google.android.apps.photos.onboarding.IntroActivity']
|
package + '/com.google.android.apps.photos.onboarding.IntroActivity']
|
||||||
description = """
|
description = '''
|
||||||
A workload to perform standard productivity tasks with Google Photos. The workload carries out
|
A workload to perform standard productivity tasks with Google Photos. The workload carries out
|
||||||
various tasks, such as browsing images, performing zooms, and post-processing the image.
|
various tasks, such as browsing images, performing zooms, and post-processing the image.
|
||||||
|
|
||||||
Test description:
|
Test description:
|
||||||
1. Four images are copied to the device
|
1. Four images are copied to the device
|
||||||
2. The application is started in offline access mode
|
2. The application is started in offline access mode
|
||||||
3. Gestures are performed to swipe between images and pinch zoom in and out of the selected
|
3. Gestures are performed to pinch zoom in and out of the selected image
|
||||||
image
|
|
||||||
4. The colour of a selected image is edited by selecting the colour menu, incrementing the
|
4. The colour of a selected image is edited by selecting the colour menu, incrementing the
|
||||||
colour, resetting the colour and decrementing the colour using the seek bar.
|
colour, resetting the colour and decrementing the colour using the seek bar.
|
||||||
5. A crop test is performed on a selected image. UiAutomator does not allow the selection of
|
5. A crop test is performed on a selected image. UiAutomator does not allow the selection of
|
||||||
@ -48,7 +47,7 @@ class Googlephotos(AndroidUxPerfWorkload):
|
|||||||
similar cropping effect.
|
similar cropping effect.
|
||||||
6. A rotate test is performed on a selected image, rotating anticlockwise 90 degrees, 180
|
6. A rotate test is performed on a selected image, rotating anticlockwise 90 degrees, 180
|
||||||
degrees and 270 degrees.
|
degrees and 270 degrees.
|
||||||
"""
|
'''
|
||||||
|
|
||||||
default_test_images = [
|
default_test_images = [
|
||||||
'uxperf_1200x1600.png', 'uxperf_1600x1200.jpg',
|
'uxperf_1200x1600.png', 'uxperf_1600x1200.jpg',
|
||||||
@ -58,10 +57,10 @@ class Googlephotos(AndroidUxPerfWorkload):
|
|||||||
parameters = [
|
parameters = [
|
||||||
Parameter('test_images', kind=list_of_strings, default=default_test_images,
|
Parameter('test_images', kind=list_of_strings, default=default_test_images,
|
||||||
constraint=lambda x: len(unique(x)) == 4,
|
constraint=lambda x: len(unique(x)) == 4,
|
||||||
description="""
|
description='''
|
||||||
A list of four JPEG and/or PNG files to be pushed to the device.
|
A list of four JPEG and/or PNG files to be pushed to the device.
|
||||||
Absolute file paths may be used but tilde expansion must be escaped.
|
Absolute file paths may be used but tilde expansion must be escaped.
|
||||||
"""),
|
'''),
|
||||||
]
|
]
|
||||||
|
|
||||||
def __init__(self, device, **kwargs):
|
def __init__(self, device, **kwargs):
|
||||||
@ -70,20 +69,29 @@ class Googlephotos(AndroidUxPerfWorkload):
|
|||||||
|
|
||||||
def validate(self):
|
def validate(self):
|
||||||
super(Googlephotos, self).validate()
|
super(Googlephotos, self).validate()
|
||||||
|
# Only accept certain image formats
|
||||||
for image in self.test_images:
|
for image in self.test_images:
|
||||||
if os.path.splitext(image.lower())[1] not in ['.jpg', '.jpeg', '.png']:
|
if os.path.splitext(image.lower())[1] not in ['.jpg', '.jpeg', '.png']:
|
||||||
raise ValidationError('{} must be a JPEG or PNG file'.format(image))
|
raise ValidationError('{} must be a JPEG or PNG file'.format(image))
|
||||||
|
|
||||||
def setup(self, context):
|
def setup(self, context):
|
||||||
super(Googlephotos, self).setup(context)
|
super(Googlephotos, self).setup(context)
|
||||||
|
# Create a subfolder for each test_image named ``wa-[1-4]``
|
||||||
|
# Move each image into its subfolder
|
||||||
|
# This is to guarantee ordering and allows the workload to select a specific
|
||||||
|
# image by subfolder, as filenames are not shown easily within the app
|
||||||
|
d = self.device.working_directory
|
||||||
|
for i, f in enumerate(self.test_images):
|
||||||
|
self.device.execute('mkdir -p {0}/wa-{1}'.format(d, i + 1))
|
||||||
|
self.device.execute('mv {0}/{2} {0}/wa-{1}/{2}'.format(d, i + 1, f))
|
||||||
|
# Force rescan
|
||||||
self.device.broadcast_media_mounted(self.device.working_directory)
|
self.device.broadcast_media_mounted(self.device.working_directory)
|
||||||
|
|
||||||
def teardown(self, context):
|
def teardown(self, context):
|
||||||
super(Googlephotos, self).teardown(context)
|
super(Googlephotos, self).teardown(context)
|
||||||
self.device.broadcast_media_mounted(self.device.working_directory)
|
# Remove the subfolders and its content
|
||||||
|
d = self.device.working_directory
|
||||||
def finalize(self, context):
|
for i in xrange(len(self.test_images)):
|
||||||
super(Googlephotos, self).finalize(context)
|
self.device.execute('rm -rf {0}/wa-{1}'.format(d, i + 1))
|
||||||
self.delete_assets()
|
# Force rescan
|
||||||
self.device.broadcast_media_mounted(self.device.working_directory)
|
self.device.broadcast_media_mounted(self.device.working_directory)
|
||||||
|
Binary file not shown.
@ -26,6 +26,10 @@ import com.android.uiautomator.core.UiScrollable;
|
|||||||
|
|
||||||
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
|
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
|
||||||
|
|
||||||
|
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_ID;
|
||||||
|
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_TEXT;
|
||||||
|
import static com.arm.wlauto.uiauto.BaseUiAutomation.FindByCriteria.BY_DESC;
|
||||||
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.LinkedHashMap;
|
import java.util.LinkedHashMap;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
@ -34,14 +38,11 @@ import java.util.Map.Entry;
|
|||||||
|
|
||||||
public class UiAutomation extends UxPerfUiAutomation {
|
public class UiAutomation extends UxPerfUiAutomation {
|
||||||
|
|
||||||
public static String TAG = "uxperf_googlephotos";
|
|
||||||
|
|
||||||
public Bundle parameters;
|
public Bundle parameters;
|
||||||
public String packageName;
|
public String packageName;
|
||||||
public String packageID;
|
public String packageID;
|
||||||
|
|
||||||
private int viewTimeoutSecs = 10;
|
private long viewTimeout = TimeUnit.SECONDS.toMillis(10);
|
||||||
private long viewTimeout = TimeUnit.SECONDS.toMillis(viewTimeoutSecs);
|
|
||||||
|
|
||||||
public void runUiAutomation() throws Exception {
|
public void runUiAutomation() throws Exception {
|
||||||
parameters = getParams();
|
parameters = getParams();
|
||||||
@ -52,11 +53,25 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
setScreenOrientation(ScreenOrientation.NATURAL);
|
setScreenOrientation(ScreenOrientation.NATURAL);
|
||||||
dismissWelcomeView();
|
dismissWelcomeView();
|
||||||
closePromotionPopUp();
|
closePromotionPopUp();
|
||||||
selectWorkingGallery();
|
|
||||||
|
selectWorkingGallery("wa-1");
|
||||||
gesturesTest();
|
gesturesTest();
|
||||||
|
navigateUp();
|
||||||
|
|
||||||
|
selectWorkingGallery("wa-2");
|
||||||
editPhotoColorTest();
|
editPhotoColorTest();
|
||||||
|
closeAndReturn(true);
|
||||||
|
navigateUp();
|
||||||
|
|
||||||
|
selectWorkingGallery("wa-3");
|
||||||
cropPhotoTest();
|
cropPhotoTest();
|
||||||
|
closeAndReturn(true);
|
||||||
|
navigateUp();
|
||||||
|
|
||||||
|
selectWorkingGallery("wa-4");
|
||||||
rotatePhotoTest();
|
rotatePhotoTest();
|
||||||
|
closeAndReturn(true);
|
||||||
|
|
||||||
unsetScreenOrientation();
|
unsetScreenOrientation();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -67,7 +82,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
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"));
|
||||||
|
|
||||||
if (getStartedButton.waitForExists(viewTimeout)) {
|
if (getStartedButton.waitForExists(viewTimeout)) {
|
||||||
getStartedButton.click();
|
getStartedButton.click();
|
||||||
}
|
}
|
||||||
@ -78,25 +92,17 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
// pathways when dismissing welcome views here.
|
// pathways when dismissing welcome views here.
|
||||||
UiObject doNotSignInButton =
|
UiObject doNotSignInButton =
|
||||||
new UiObject(new UiSelector().resourceId(packageID + "dont_sign_in_button"));
|
new UiObject(new UiSelector().resourceId(packageID + "dont_sign_in_button"));
|
||||||
|
|
||||||
if (doNotSignInButton.exists()) {
|
if (doNotSignInButton.exists()) {
|
||||||
doNotSignInButton.click();
|
doNotSignInButton.click();
|
||||||
} else {
|
} else {
|
||||||
UiObject welcomeButton =
|
clickUiObject(BY_ID, packageID + "name", "android.widget.TextView");
|
||||||
getUiObjectByResourceId(packageID + "name",
|
clickUiObject(BY_TEXT, "Use without an account", "android.widget.TextView", true);
|
||||||
"android.widget.TextView");
|
|
||||||
welcomeButton.click();
|
|
||||||
|
|
||||||
UiObject useWithoutAccount =
|
|
||||||
getUiObjectByText("Use without an account", "android.widget.TextView");
|
|
||||||
useWithoutAccount.clickAndWaitForNewWindow();
|
|
||||||
|
|
||||||
// Folder containing test images (early check required)
|
|
||||||
UiObject workingFolder = new UiObject(new UiSelector().text("wa-working"));
|
|
||||||
|
|
||||||
// On some devices the welcome views don't always appear so check
|
// On some devices the welcome views don't always appear so check
|
||||||
// for the existence of the wa-working directory before attempting
|
// for the existence of the wa-working directory before attempting
|
||||||
// to dismiss welcome views promoting app features
|
// to dismiss welcome views promoting app features
|
||||||
|
UiObject workingFolder =
|
||||||
|
new UiObject(new UiSelector().text("wa-working"));
|
||||||
if (!workingFolder.exists()) {
|
if (!workingFolder.exists()) {
|
||||||
sleep(1);
|
sleep(1);
|
||||||
uiDeviceSwipeLeft(10);
|
uiDeviceSwipeLeft(10);
|
||||||
@ -111,7 +117,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
UiObject nextButton =
|
UiObject nextButton =
|
||||||
new UiObject(new UiSelector().resourceId(packageID + "next_button")
|
new UiObject(new UiSelector().resourceId(packageID + "next_button")
|
||||||
.className("android.widget.ImageView"));
|
.className("android.widget.ImageView"));
|
||||||
|
|
||||||
if (nextButton.exists()) {
|
if (nextButton.exists()) {
|
||||||
nextButton.clickAndWaitForNewWindow();
|
nextButton.clickAndWaitForNewWindow();
|
||||||
}
|
}
|
||||||
@ -120,22 +125,22 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
public void closePromotionPopUp() throws Exception {
|
public void closePromotionPopUp() throws Exception {
|
||||||
UiObject promoCloseButton =
|
UiObject promoCloseButton =
|
||||||
new UiObject(new UiSelector().resourceId(packageID + "promo_close_button"));
|
new UiObject(new UiSelector().resourceId(packageID + "promo_close_button"));
|
||||||
|
|
||||||
if (promoCloseButton.exists()) {
|
if (promoCloseButton.exists()) {
|
||||||
promoCloseButton.click();
|
promoCloseButton.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to click on the wa-working gallery.
|
// Helper to click on the wa-working gallery.
|
||||||
public void selectWorkingGallery() throws Exception {
|
public void selectWorkingGallery(String directory) throws Exception {
|
||||||
UiObject workdir = new UiObject(new UiSelector().text("wa-working")
|
UiObject workdir =
|
||||||
.className("android.widget.TextView"));
|
new UiObject(new UiSelector().text(directory)
|
||||||
|
.className("android.widget.TextView"));
|
||||||
|
UiScrollable scrollView =
|
||||||
|
new UiScrollable(new UiSelector().scrollable(true));
|
||||||
|
|
||||||
// If the wa-working gallery is not present wait for a short time for
|
// If the wa-working gallery is not present wait for a short time for
|
||||||
// the media server to refresh its index.
|
// the media server to refresh its index.
|
||||||
boolean discovered = workdir.waitForExists(viewTimeout);
|
boolean discovered = workdir.waitForExists(viewTimeout);
|
||||||
UiScrollable scrollView = new UiScrollable(new UiSelector().scrollable(true));
|
|
||||||
|
|
||||||
if (!discovered && scrollView.exists()) {
|
if (!discovered && scrollView.exists()) {
|
||||||
// First check if the wa-working directory is visible on the first
|
// First check if the wa-working directory is visible on the first
|
||||||
// screen and if not scroll to the bottom of the screen to look for it.
|
// screen and if not scroll to the bottom of the screen to look for it.
|
||||||
@ -162,26 +167,23 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
if (discovered) {
|
if (discovered) {
|
||||||
workdir.clickAndWaitForNewWindow();
|
workdir.clickAndWaitForNewWindow();
|
||||||
} else {
|
} else {
|
||||||
throw new UiObjectNotFoundException("Could not find \"wa-working\" folder");
|
throw new UiObjectNotFoundException("Could not find folder : " + directory);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Helper to click on an individual photograph based on index in wa-working gallery.
|
|
||||||
public void selectPhoto(final int index) throws Exception {
|
|
||||||
UiObject photo =
|
UiObject photo =
|
||||||
new UiObject(new UiSelector().resourceId(packageID + "recycler_view")
|
new UiObject(new UiSelector().resourceId(packageID + "recycler_view")
|
||||||
.childSelector(new UiSelector()
|
.childSelector(new UiSelector()
|
||||||
.index(index)));
|
.index(1)));
|
||||||
|
|
||||||
// On some versions of the app a non-zero index is used for the
|
|
||||||
// photographs position while on other versions a zero index is used.
|
|
||||||
// Try both possiblities before throwing an exception.
|
|
||||||
if (photo.exists()) {
|
if (photo.exists()) {
|
||||||
photo.click();
|
photo.click();
|
||||||
} else {
|
} else {
|
||||||
photo = new UiObject(new UiSelector().resourceId(packageID + "recycler_view")
|
// On some versions of the app a non-zero index is used for the
|
||||||
.childSelector(new UiSelector()
|
// photographs position while on other versions a zero index is used.
|
||||||
.index(index - 1)));
|
// Try both possiblities before throwing an exception.
|
||||||
|
photo =
|
||||||
|
new UiObject(new UiSelector().resourceId(packageID + "recycler_view")
|
||||||
|
.childSelector(new UiSelector()
|
||||||
|
.index(0)));
|
||||||
photo.click();
|
photo.click();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -189,11 +191,13 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
// Helper that accepts, closes and navigates back to application home screen after an edit operation.
|
// Helper that accepts, closes and navigates back to application home screen after an edit operation.
|
||||||
// dontsave - True will discard the image. False will save the image
|
// dontsave - True will discard the image. False will save the image
|
||||||
public void closeAndReturn(final boolean dontsave) throws Exception {
|
public void closeAndReturn(final boolean dontsave) throws Exception {
|
||||||
UiObject accept = new UiObject(new UiSelector().description("Accept"));
|
|
||||||
UiObject done = new UiObject(new UiSelector().resourceId(packageID + "cpe_save_button"));
|
|
||||||
|
|
||||||
long timeout = TimeUnit.SECONDS.toMillis(3);
|
long timeout = TimeUnit.SECONDS.toMillis(3);
|
||||||
|
|
||||||
|
UiObject accept =
|
||||||
|
new UiObject(new UiSelector().description("Accept"));
|
||||||
|
UiObject done =
|
||||||
|
new UiObject(new UiSelector().resourceId(packageID + "cpe_save_button"));
|
||||||
|
|
||||||
// On some edit operations we can either confirm an edit with "Accept" or "DONE"
|
// On some edit operations we can either confirm an edit with "Accept" or "DONE"
|
||||||
if (accept.waitForExists(timeout)) {
|
if (accept.waitForExists(timeout)) {
|
||||||
accept.click();
|
accept.click();
|
||||||
@ -204,8 +208,7 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (dontsave) {
|
if (dontsave) {
|
||||||
UiObject close = getUiObjectByDescription("Close editor", "android.widget.ImageView");
|
clickUiObject(BY_DESC, "Close editor", "android.widget.ImageView");
|
||||||
close.click();
|
|
||||||
|
|
||||||
UiObject discard = getUiObjectByText("DISCARD", "android.widget.Button");
|
UiObject discard = getUiObjectByText("DISCARD", "android.widget.Button");
|
||||||
discard.waitForExists(viewTimeout);
|
discard.waitForExists(viewTimeout);
|
||||||
@ -215,12 +218,12 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
save.waitForExists(viewTimeout);
|
save.waitForExists(viewTimeout);
|
||||||
save.click();
|
save.click();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void navigateUp() throws Exception {
|
||||||
UiObject navigateUpButton =
|
UiObject navigateUpButton =
|
||||||
new UiObject(new UiSelector().descriptionContains("Navigate Up")
|
clickUiObject(BY_DESC, "Navigate Up", "android.widget.ImageButton", true);
|
||||||
.className("android.widget.ImageButton"));
|
navigateUpButton.clickAndWaitForNewWindow();
|
||||||
navigateUpButton.waitForExists(viewTimeout);
|
|
||||||
navigateUpButton.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void gesturesTest() throws Exception {
|
private void gesturesTest() throws Exception {
|
||||||
@ -228,26 +231,20 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
|
|
||||||
// Perform a range of swipe tests while browsing photo gallery
|
// Perform a range of swipe tests while browsing photo gallery
|
||||||
LinkedHashMap<String, GestureTestParams> testParams = new LinkedHashMap<String, GestureTestParams>();
|
LinkedHashMap<String, GestureTestParams> testParams = new LinkedHashMap<String, GestureTestParams>();
|
||||||
testParams.put("swipe_left", new GestureTestParams(GestureType.UIDEVICE_SWIPE, Direction.LEFT, 10));
|
|
||||||
testParams.put("pinch_out", new GestureTestParams(GestureType.PINCH, PinchType.OUT, 100, 50));
|
testParams.put("pinch_out", new GestureTestParams(GestureType.PINCH, PinchType.OUT, 100, 50));
|
||||||
testParams.put("pinch_in", new GestureTestParams(GestureType.PINCH, PinchType.IN, 100, 50));
|
testParams.put("pinch_in", new GestureTestParams(GestureType.PINCH, PinchType.IN, 100, 50));
|
||||||
testParams.put("swipe_right", new GestureTestParams(GestureType.UIDEVICE_SWIPE, Direction.RIGHT, 10));
|
|
||||||
|
|
||||||
Iterator<Entry<String, GestureTestParams>> it = testParams.entrySet().iterator();
|
Iterator<Entry<String, GestureTestParams>> it = testParams.entrySet().iterator();
|
||||||
|
|
||||||
// Select first photograph
|
|
||||||
selectPhoto(1);
|
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, GestureTestParams> pair = it.next();
|
Map.Entry<String, GestureTestParams> pair = it.next();
|
||||||
GestureType type = pair.getValue().gestureType;
|
GestureType type = pair.getValue().gestureType;
|
||||||
Direction dir = pair.getValue().gestureDirection;
|
|
||||||
PinchType pinch = pair.getValue().pinchType;
|
PinchType pinch = pair.getValue().pinchType;
|
||||||
int steps = pair.getValue().steps;
|
int steps = pair.getValue().steps;
|
||||||
int percent = pair.getValue().percent;
|
int percent = pair.getValue().percent;
|
||||||
|
|
||||||
UiObject view = new UiObject(new UiSelector().enabled(true));
|
UiObject view =
|
||||||
|
new UiObject(new UiSelector().enabled(true));
|
||||||
if (!view.waitForExists(viewTimeout)) {
|
if (!view.waitForExists(viewTimeout)) {
|
||||||
throw new UiObjectNotFoundException("Could not find \"photo view\".");
|
throw new UiObjectNotFoundException("Could not find \"photo view\".");
|
||||||
}
|
}
|
||||||
@ -257,9 +254,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
logger.start();
|
logger.start();
|
||||||
|
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case UIDEVICE_SWIPE:
|
|
||||||
uiDeviceSwipe(dir, steps);
|
|
||||||
break;
|
|
||||||
case PINCH:
|
case PINCH:
|
||||||
uiObjectVertPinch(view, pinch, steps, percent);
|
uiObjectVertPinch(view, pinch, steps, percent);
|
||||||
break;
|
break;
|
||||||
@ -269,48 +263,40 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
|
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
UiObject navigateUpButton =
|
|
||||||
getUiObjectByDescription("Navigate Up", "android.widget.ImageButton");
|
|
||||||
navigateUpButton.click();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public enum Position { LEFT, RIGHT, CENTRE };
|
public enum Position { LEFT, RIGHT, CENTRE };
|
||||||
|
|
||||||
private class SeekBarTestParams {
|
private class PositionPair {
|
||||||
|
private Position start;
|
||||||
|
private Position end;
|
||||||
|
|
||||||
private Position seekBarPosition;
|
PositionPair(final Position start, final Position end) {
|
||||||
private int percent;
|
this.start = start;
|
||||||
private int steps;
|
this.end = end;
|
||||||
|
|
||||||
SeekBarTestParams(final Position position, final int steps, final int percent) {
|
|
||||||
this.seekBarPosition = position;
|
|
||||||
this.steps = steps;
|
|
||||||
this.percent = percent;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void editPhotoColorTest() throws Exception {
|
private void editPhotoColorTest() throws Exception {
|
||||||
|
long timeout = TimeUnit.SECONDS.toMillis(3);
|
||||||
|
// To improve travel accuracy perform the slide bar operation slowly
|
||||||
|
final int steps = 100;
|
||||||
|
|
||||||
String testTag = "edit";
|
String testTag = "edit";
|
||||||
|
|
||||||
// Perform a range of swipe tests while browsing photo gallery
|
// Perform a range of swipe tests while browsing photo gallery
|
||||||
LinkedHashMap<String, SeekBarTestParams> testParams = new LinkedHashMap<String, SeekBarTestParams>();
|
LinkedHashMap<String, PositionPair> testParams = new LinkedHashMap<String, PositionPair>();
|
||||||
testParams.put("color_increment", new SeekBarTestParams(Position.RIGHT, 10, 20));
|
testParams.put("color_increment", new PositionPair(Position.CENTRE, Position.RIGHT));
|
||||||
testParams.put("color_reset", new SeekBarTestParams(Position.CENTRE, 0, 0));
|
testParams.put("color_reset", new PositionPair(Position.RIGHT, Position.CENTRE));
|
||||||
testParams.put("color_decrement", new SeekBarTestParams(Position.LEFT, 10, 20));
|
testParams.put("color_decrement", new PositionPair(Position.CENTRE, Position.LEFT));
|
||||||
|
|
||||||
Iterator<Entry<String, SeekBarTestParams>> it = testParams.entrySet().iterator();
|
Iterator<Entry<String, PositionPair>> it = testParams.entrySet().iterator();
|
||||||
|
|
||||||
// Select second photograph
|
clickUiObject(BY_ID, packageID + "edit", "android.widget.ImageView");
|
||||||
selectPhoto(2);
|
|
||||||
|
|
||||||
UiObject editView = getUiObjectByResourceId(packageID + "edit",
|
|
||||||
"android.widget.ImageView");
|
|
||||||
editView.click();
|
|
||||||
|
|
||||||
// Manage potential different spelling of UI element
|
// Manage potential different spelling of UI element
|
||||||
UiObject editCol = new UiObject(new UiSelector().textMatches("Colou?r"));
|
UiObject editCol =
|
||||||
long timeout = TimeUnit.SECONDS.toMillis(3);
|
new UiObject(new UiSelector().textMatches("Colou?r"));
|
||||||
if (editCol.waitForExists(timeout)) {
|
if (editCol.waitForExists(timeout)) {
|
||||||
editCol.click();
|
editCol.click();
|
||||||
} else {
|
} else {
|
||||||
@ -318,33 +304,29 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
"Color/Colour", "android.widget.RadioButton"));
|
"Color/Colour", "android.widget.RadioButton"));
|
||||||
}
|
}
|
||||||
|
|
||||||
UiObject seekBar = getUiObjectByResourceId(packageID + "cpe_strength_seek_bar",
|
UiObject seekBar =
|
||||||
"android.widget.SeekBar");
|
getUiObjectByResourceId(packageID + "cpe_strength_seek_bar",
|
||||||
|
"android.widget.SeekBar");
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, SeekBarTestParams> pair = it.next();
|
Map.Entry<String, PositionPair> pair = it.next();
|
||||||
Position pos = pair.getValue().seekBarPosition;
|
Position start = pair.getValue().start;
|
||||||
int steps = pair.getValue().steps;
|
Position end = pair.getValue().end;
|
||||||
int percent = pair.getValue().percent;
|
|
||||||
|
|
||||||
String runName = String.format(testTag + "_" + pair.getKey());
|
String runName = String.format(testTag + "_" + pair.getKey());
|
||||||
ActionLogger logger = new ActionLogger(runName, parameters);
|
ActionLogger logger = new ActionLogger(runName, parameters);
|
||||||
|
|
||||||
sleep(1); // pause for stability before editing the colour
|
|
||||||
|
|
||||||
logger.start();
|
logger.start();
|
||||||
seekBarTest(seekBar, pos, steps);
|
seekBarTest(seekBar, start, end, steps);
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
closeAndReturn(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void cropPhotoTest() throws Exception {
|
private void cropPhotoTest() throws Exception {
|
||||||
String testTag = "crop";
|
String testTag = "crop";
|
||||||
|
|
||||||
// To improve travel accuracy perform the slide bar operation slowly
|
// To improve travel accuracy perform the slide bar operation slowly
|
||||||
final int steps = 500;
|
final int steps = 100;
|
||||||
|
|
||||||
// Perform a range of swipe tests while browsing photo gallery
|
// Perform a range of swipe tests while browsing photo gallery
|
||||||
LinkedHashMap<String, Position> testParams = new LinkedHashMap<String, Position>();
|
LinkedHashMap<String, Position> testParams = new LinkedHashMap<String, Position>();
|
||||||
@ -354,18 +336,11 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
|
|
||||||
Iterator<Entry<String, Position>> it = testParams.entrySet().iterator();
|
Iterator<Entry<String, Position>> it = testParams.entrySet().iterator();
|
||||||
|
|
||||||
// Select third photograph
|
clickUiObject(BY_ID, packageID + "edit", "android.widget.ImageView");
|
||||||
selectPhoto(3);
|
clickUiObject(BY_ID, packageID + "cpe_crop_tool", "android.widget.ImageView");
|
||||||
|
|
||||||
UiObject editView = getUiObjectByResourceId(packageID + "edit",
|
UiObject straightenSlider =
|
||||||
"android.widget.ImageView");
|
getUiObjectByResourceId(packageID + "cpe_straighten_slider");
|
||||||
editView.click();
|
|
||||||
|
|
||||||
UiObject cropTool = getUiObjectByResourceId(packageID + "cpe_crop_tool",
|
|
||||||
"android.widget.ImageView");
|
|
||||||
cropTool.click();
|
|
||||||
|
|
||||||
UiObject straightenSlider = getUiObjectByResourceId(packageID + "cpe_straighten_slider");
|
|
||||||
|
|
||||||
while (it.hasNext()) {
|
while (it.hasNext()) {
|
||||||
Map.Entry<String, Position> pair = it.next();
|
Map.Entry<String, Position> pair = it.next();
|
||||||
@ -378,8 +353,6 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
slideBarTest(straightenSlider, pos, steps);
|
slideBarTest(straightenSlider, pos, steps);
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
closeAndReturn(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void rotatePhotoTest() throws Exception {
|
private void rotatePhotoTest() throws Exception {
|
||||||
@ -387,17 +360,11 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
|
|
||||||
String[] subTests = {"90", "180", "270"};
|
String[] subTests = {"90", "180", "270"};
|
||||||
|
|
||||||
// Select fourth photograph
|
clickUiObject(BY_ID, packageID + "edit", "android.widget.ImageView");
|
||||||
selectPhoto(4);
|
clickUiObject(BY_ID, packageID + "cpe_crop_tool", "android.widget.ImageView");
|
||||||
|
|
||||||
UiObject editView = getUiObjectByResourceId(packageID + "edit",
|
UiObject rotate =
|
||||||
"android.widget.ImageView");
|
getUiObjectByResourceId(packageID + "cpe_rotate_90");
|
||||||
editView.click();
|
|
||||||
|
|
||||||
UiObject cropTool = getUiObjectByResourceId(packageID + "cpe_crop_tool");
|
|
||||||
cropTool.click();
|
|
||||||
|
|
||||||
UiObject rotate = getUiObjectByResourceId(packageID + "cpe_rotate_90");
|
|
||||||
|
|
||||||
for (String subTest : subTests) {
|
for (String subTest : subTests) {
|
||||||
String runName = String.format(testTag + "_" + subTest);
|
String runName = String.format(testTag + "_" + subTest);
|
||||||
@ -407,28 +374,45 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
rotate.click();
|
rotate.click();
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
closeAndReturn(true);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to slide the seekbar during photo edit.
|
// Helper to slide the seekbar during photo edit.
|
||||||
private void seekBarTest(final UiObject view, final Position pos, final int steps) throws Exception {
|
private void seekBarTest(final UiObject view, final Position start, final Position end, final int steps) throws Exception {
|
||||||
final int SWIPE_MARGIN_LIMIT = 5;
|
final int SWIPE_MARGIN_LIMIT = 5;
|
||||||
Rect rect = view.getVisibleBounds();
|
Rect rect = view.getVisibleBounds();
|
||||||
|
int startX, endX;
|
||||||
|
|
||||||
switch (pos) {
|
switch (start) {
|
||||||
|
case CENTRE:
|
||||||
|
startX = rect.centerX();
|
||||||
|
break;
|
||||||
case LEFT:
|
case LEFT:
|
||||||
getUiDevice().click(rect.left + SWIPE_MARGIN_LIMIT, rect.centerY());
|
startX = rect.left + SWIPE_MARGIN_LIMIT;
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
getUiDevice().click(rect.right - SWIPE_MARGIN_LIMIT, rect.centerY());
|
startX = rect.right - SWIPE_MARGIN_LIMIT;
|
||||||
break;
|
|
||||||
case CENTRE:
|
|
||||||
view.click();
|
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
startX = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
switch (end) {
|
||||||
|
case CENTRE:
|
||||||
|
endX = rect.centerX();
|
||||||
|
break;
|
||||||
|
case LEFT:
|
||||||
|
endX = rect.left + SWIPE_MARGIN_LIMIT;
|
||||||
|
break;
|
||||||
|
case RIGHT:
|
||||||
|
endX = rect.right - SWIPE_MARGIN_LIMIT;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
endX = 0;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
getUiDevice().drag(startX, rect.centerY(), endX, rect.centerY(), steps);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Helper to slide the slidebar during photo edit.
|
// Helper to slide the slidebar during photo edit.
|
||||||
@ -439,12 +423,12 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
switch (pos) {
|
switch (pos) {
|
||||||
case LEFT:
|
case LEFT:
|
||||||
getUiDevice().drag(rect.left + SWIPE_MARGIN_LIMIT, rect.centerY(),
|
getUiDevice().drag(rect.left + SWIPE_MARGIN_LIMIT, rect.centerY(),
|
||||||
rect.left + rect.width() / 4, rect.centerY(),
|
rect.left + (rect.width() / 4), rect.centerY(),
|
||||||
steps);
|
steps);
|
||||||
break;
|
break;
|
||||||
case RIGHT:
|
case RIGHT:
|
||||||
getUiDevice().drag(rect.right - SWIPE_MARGIN_LIMIT, rect.centerY(),
|
getUiDevice().drag(rect.right - SWIPE_MARGIN_LIMIT, rect.centerY(),
|
||||||
rect.right - rect.width() / 4, rect.centerY(),
|
rect.right - (rect.width() / 4), rect.centerY(),
|
||||||
steps);
|
steps);
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
|
Loading…
x
Reference in New Issue
Block a user