1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2024-10-05 18:31:12 +01:00

workloads/gmail: Fix to use passed working directory parameter

In devlib the default working directory has changed causing the workload
to look in the wrong directory, now the workload should use the passed
working directory and extract the relevant name from there.
This commit is contained in:
Marc Bonnici 2018-01-31 16:25:23 +00:00 committed by setrofim
parent e5ed64d8d5
commit cba773b5e6
3 changed files with 11 additions and 5 deletions

View File

@ -65,6 +65,10 @@ class Gmail(ApkUiautoWorkload):
super(Gmail, self).init_resources(context)
if self.target.get_sdk_version() >= 24 and 'com.google.android.apps.photos' not in self.target.list_packages():
raise WorkloadError('gmail workload requires Google Photos to be installed for Android N onwards')
# Allows for getting working directory regardless if path ends with a '/'
work_dir = self.target.working_directory
work_dir = work_dir if work_dir[-1] != os.sep else work_dir[:-1]
self.gui.uiauto_params['workdir_name'] = self.target.path.basename(work_dir)
self.gui.uiauto_params['recipient'] = self.recipient
# Only accept certain image formats
if os.path.splitext(self.test_image.lower())[1] not in ['.jpg', '.jpeg', '.png']:

View File

@ -38,6 +38,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
protected Bundle parameters;
protected String packageID;
protected String recipient;
protected String workdir_name;
private int networkTimeoutSecs = 30;
private long networkTimeout = TimeUnit.SECONDS.toMillis(networkTimeoutSecs);
@ -47,6 +48,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
parameters = getParams();
packageID = getPackageID(parameters);
recipient = parameters.getString("recipient");
workdir_name = parameters.getString("workdir_name");
}
@Test
@ -203,10 +205,10 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
} else {
photos.click();
//Click wa folder image
UiObject waFolder =
mDevice.findObject(new UiSelector().textContains("wa")
UiObject working_directory =
mDevice.findObject(new UiSelector().textContains(workdir_name)
.className("android.widget.TextView"));
if (!waFolder.waitForExists (uiAutoTimeout)) {
if (!working_directory.waitForExists (uiAutoTimeout)) {
UiObject refresh =
getUiObjectByResourceId("com.google.android.apps.photos:id/image");
refresh.clickAndWaitForNewWindow();
@ -214,8 +216,8 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
getUiObjectByResourceId("com.google.android.apps.photos:id/action_mode_close_button");
back.clickAndWaitForNewWindow();
}
waFolder.waitForExists (uiAutoTimeout);
waFolder.click();
working_directory.waitForExists (uiAutoTimeout);
working_directory.click();
//Click test image
UiObject imageFileButton =
mDevice.findObject(new UiSelector().descriptionContains("Photo"));