mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-21 01:59:13 +00:00
Update gmail workload to work against most recent version
* Updated gmail to work against 2019.05.26.252424914.release.
This commit is contained in:
parent
ab5d12be72
commit
e9043b9b3c
@ -44,7 +44,7 @@ class Gmail(ApkUiautoWorkload):
|
|||||||
The result should then be placed in the '~/.workload_automation/dependencies/gmail/' directory
|
The result should then be placed in the '~/.workload_automation/dependencies/gmail/' directory
|
||||||
on your local machine, creating this if it does not already exist.
|
on your local machine, creating this if it does not already exist.
|
||||||
|
|
||||||
Known working APK version: 7.11.5.176133587
|
Known working APK version: 2019.05.26.252424914.release
|
||||||
'''
|
'''
|
||||||
|
|
||||||
parameters = [
|
parameters = [
|
||||||
@ -90,14 +90,13 @@ class Gmail(ApkUiautoWorkload):
|
|||||||
|
|
||||||
def init_resources(self, context):
|
def init_resources(self, context):
|
||||||
super(Gmail, self).init_resources(context)
|
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 '/'
|
# Allows for getting working directory regardless if path ends with a '/'
|
||||||
work_dir = self.target.working_directory
|
work_dir = self.target.working_directory
|
||||||
work_dir = work_dir if work_dir[-1] != os.sep else work_dir[:-1]
|
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['workdir_name'] = self.target.path.basename(work_dir)
|
||||||
self.gui.uiauto_params['recipient'] = self.recipient
|
self.gui.uiauto_params['recipient'] = self.recipient
|
||||||
self.gui.uiauto_params['offline_mode'] = self.offline_mode
|
self.gui.uiauto_params['offline_mode'] = self.offline_mode
|
||||||
|
self.gui.uiauto_params['test_image'] = self.test_image
|
||||||
# Only accept certain image formats
|
# Only accept certain image formats
|
||||||
if os.path.splitext(self.test_image.lower())[1] not in ['.jpg', '.jpeg', '.png']:
|
if os.path.splitext(self.test_image.lower())[1] not in ['.jpg', '.jpeg', '.png']:
|
||||||
raise ValidationError('{} must be a JPEG or PNG file'.format(self.test_image))
|
raise ValidationError('{} must be a JPEG or PNG file'.format(self.test_image))
|
||||||
|
Binary file not shown.
@ -20,6 +20,7 @@ import android.support.test.runner.AndroidJUnit4;
|
|||||||
import android.support.test.uiautomator.UiObject;
|
import android.support.test.uiautomator.UiObject;
|
||||||
import android.support.test.uiautomator.UiObjectNotFoundException;
|
import android.support.test.uiautomator.UiObjectNotFoundException;
|
||||||
import android.support.test.uiautomator.UiSelector;
|
import android.support.test.uiautomator.UiSelector;
|
||||||
|
import android.util.Log;
|
||||||
|
|
||||||
import com.arm.wa.uiauto.ApplaunchInterface;
|
import com.arm.wa.uiauto.ApplaunchInterface;
|
||||||
import com.arm.wa.uiauto.BaseUiAutomation;
|
import com.arm.wa.uiauto.BaseUiAutomation;
|
||||||
@ -40,6 +41,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
protected String recipient;
|
protected String recipient;
|
||||||
protected String workdir_name;
|
protected String workdir_name;
|
||||||
protected boolean offlineMode;
|
protected boolean offlineMode;
|
||||||
|
protected String test_image;
|
||||||
|
|
||||||
private int networkTimeoutSecs = 30;
|
private int networkTimeoutSecs = 30;
|
||||||
private long networkTimeout = TimeUnit.SECONDS.toMillis(networkTimeoutSecs);
|
private long networkTimeout = TimeUnit.SECONDS.toMillis(networkTimeoutSecs);
|
||||||
@ -51,6 +53,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
recipient = parameters.getString("recipient");
|
recipient = parameters.getString("recipient");
|
||||||
workdir_name = parameters.getString("workdir_name");
|
workdir_name = parameters.getString("workdir_name");
|
||||||
offlineMode = parameters.getBoolean("offline_mode");
|
offlineMode = parameters.getBoolean("offline_mode");
|
||||||
|
test_image = parameters.getString("test_image");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -112,6 +115,26 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
.className("android.widget.TextView"));
|
.className("android.widget.TextView"));
|
||||||
if (takeMeToBox.exists()) {
|
if (takeMeToBox.exists()) {
|
||||||
takeMeToBox.clickAndWaitForNewWindow(uiAutoTimeout);
|
takeMeToBox.clickAndWaitForNewWindow(uiAutoTimeout);
|
||||||
|
|
||||||
|
UiObject noEmailAddressMessage = mDevice.findObject(new UiSelector()
|
||||||
|
.textContains("Please add at least one email address.")
|
||||||
|
.className("android.widget.TextView"));
|
||||||
|
|
||||||
|
if (noEmailAddressMessage.exists()) {
|
||||||
|
throw new UiObjectNotFoundException("No email account setup on device. Set up at least one email address");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Dismiss fresh new look pop up messages
|
||||||
|
UiObject newLookMessageDismissButton =
|
||||||
|
mDevice.findObject(new UiSelector().resourceId(packageID + "gm_dismiss_button")
|
||||||
|
.className("android.widget.Button"));
|
||||||
|
if(newLookMessageDismissButton.exists()) {
|
||||||
|
newLookMessageDismissButton.click();
|
||||||
|
}
|
||||||
|
//Dismiss secondary message also with same button
|
||||||
|
if(newLookMessageDismissButton.exists()) {
|
||||||
|
newLookMessageDismissButton.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we're in offline mode we don't need to worry about syncing, so we're done
|
// If we're in offline mode we don't need to worry about syncing, so we're done
|
||||||
@ -142,11 +165,6 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
!waitUntilNoObject(waitingSync, networkTimeoutSecs*4)) {
|
!waitUntilNoObject(waitingSync, networkTimeoutSecs*4)) {
|
||||||
throw new UiObjectNotFoundException("Device cannot sync! Try rebooting or clearing app data");
|
throw new UiObjectNotFoundException("Device cannot sync! Try rebooting or clearing app data");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
public void clickNewMail() throws Exception {
|
|
||||||
String testTag = "click_new";
|
|
||||||
ActionLogger logger = new ActionLogger(testTag, parameters);
|
|
||||||
|
|
||||||
UiObject conversationView =
|
UiObject conversationView =
|
||||||
mDevice.findObject(new UiSelector().resourceIdMatches(packageID + "conversation_list.*"));
|
mDevice.findObject(new UiSelector().resourceIdMatches(packageID + "conversation_list.*"));
|
||||||
@ -154,8 +172,34 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
throw new UiObjectNotFoundException("Could not find \"conversationView\".");
|
throw new UiObjectNotFoundException("Could not find \"conversationView\".");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//Get rid of smart compose message on newer versions and return to home screen before ckickNewMail test
|
||||||
UiObject newMailButton =
|
UiObject newMailButton =
|
||||||
getUiObjectByDescription("Compose", "android.widget.ImageButton");
|
getUiObjectByDescription("Compose", "android.widget.ImageButton");
|
||||||
|
newMailButton.click();
|
||||||
|
|
||||||
|
UiObject smartComposeDismissButton = mDevice.findObject(new UiSelector().textContains("Got it")
|
||||||
|
.className("android.widget.Button"));
|
||||||
|
if(smartComposeDismissButton.exists()) {
|
||||||
|
smartComposeDismissButton.click();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Return to conversation/home screen
|
||||||
|
mDevice.pressBack();
|
||||||
|
if(!conversationView.exists()) {
|
||||||
|
mDevice.pressBack();
|
||||||
|
}
|
||||||
|
if(!conversationView.exists()) {
|
||||||
|
mDevice.pressBack();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public void clickNewMail() throws Exception {
|
||||||
|
String testTag = "click_new";
|
||||||
|
ActionLogger logger = new ActionLogger(testTag, parameters);
|
||||||
|
|
||||||
|
UiObject newMailButton =
|
||||||
|
getUiObjectByDescription("Compose", "android.widget.ImageButton");
|
||||||
|
|
||||||
logger.start();
|
logger.start();
|
||||||
newMailButton.clickAndWaitForNewWindow(uiAutoTimeout);
|
newMailButton.clickAndWaitForNewWindow(uiAutoTimeout);
|
||||||
logger.stop();
|
logger.stop();
|
||||||
@ -189,58 +233,55 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
if (rootMenu.exists()){
|
if (rootMenu.exists()){
|
||||||
rootMenu.click();
|
rootMenu.click();
|
||||||
}
|
}
|
||||||
// Check for Photos
|
|
||||||
UiObject photos =
|
UiObject imagesEntry =
|
||||||
mDevice.findObject(new UiSelector().text("Photos")
|
mDevice.findObject(new UiSelector().textContains("Images")
|
||||||
.className("android.widget.TextView"));
|
.className("android.widget.TextView"));
|
||||||
// If Photos does not exist use the images folder
|
if (imagesEntry.waitForExists(uiAutoTimeout)) {
|
||||||
if (!photos.waitForExists (uiAutoTimeout)) {
|
imagesEntry.click();
|
||||||
UiObject imagesEntry =
|
|
||||||
mDevice.findObject(new UiSelector().textContains("Images")
|
|
||||||
.className("android.widget.TextView"));
|
|
||||||
if (imagesEntry.waitForExists(uiAutoTimeout)) {
|
|
||||||
imagesEntry.click();
|
|
||||||
}
|
|
||||||
selectGalleryFolder(workdir_name);
|
selectGalleryFolder(workdir_name);
|
||||||
|
|
||||||
UiObject imageButton =
|
//Switch from grid view to menu view to display filename on larger screens
|
||||||
mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/grid")
|
UiObject menuListButton = mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/menu_list")
|
||||||
.className("android.widget.Gridview")
|
.className("android.widget.TextView"));
|
||||||
.childSelector(new UiSelector().index(0)
|
if (menuListButton.exists()) {
|
||||||
.className("android.widget.FrameLayout")));
|
menuListButton.click();
|
||||||
if (!imageButton.exists()){
|
}
|
||||||
imageButton =
|
|
||||||
mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/dir_list")
|
UiObject imageButton = mDevice.findObject(new UiSelector().textContains(test_image)
|
||||||
.childSelector(new UiSelector().index(0)
|
.className("android.widget.TextView"));
|
||||||
.classNameMatches("android.widget..*Layout")));
|
|
||||||
}
|
|
||||||
imageButton.click();
|
imageButton.click();
|
||||||
imageButton.waitUntilGone(uiAutoTimeout);
|
imageButton.waitUntilGone(uiAutoTimeout);
|
||||||
} else {
|
} else { // Use google photos as fallback
|
||||||
|
UiObject photos =
|
||||||
|
mDevice.findObject(new UiSelector().text("Photos")
|
||||||
|
.className("android.widget.TextView"));
|
||||||
|
|
||||||
photos.click();
|
photos.click();
|
||||||
//Click wa folder image
|
|
||||||
UiObject working_directory =
|
UiObject working_directory =
|
||||||
mDevice.findObject(new UiSelector().textContains(workdir_name)
|
mDevice.findObject(new UiSelector().textContains(workdir_name)
|
||||||
.className("android.widget.TextView"));
|
.className("android.widget.TextView"));
|
||||||
if (!working_directory.waitForExists (uiAutoTimeout)) {
|
|
||||||
UiObject refresh =
|
|
||||||
getUiObjectByResourceId("com.google.android.apps.photos:id/image");
|
|
||||||
refresh.clickAndWaitForNewWindow();
|
|
||||||
UiObject back =
|
|
||||||
getUiObjectByResourceId("com.google.android.apps.photos:id/action_mode_close_button");
|
|
||||||
back.clickAndWaitForNewWindow();
|
|
||||||
}
|
|
||||||
working_directory.waitForExists (uiAutoTimeout);
|
working_directory.waitForExists (uiAutoTimeout);
|
||||||
working_directory.click();
|
working_directory.click();
|
||||||
|
|
||||||
//Click test image
|
//Click test image
|
||||||
UiObject imageFileButton =
|
UiObject imageFileButton =
|
||||||
mDevice.findObject(new UiSelector().descriptionContains("Photo"));
|
mDevice.findObject(new UiSelector().descriptionContains("Photo"));
|
||||||
|
|
||||||
imageFileButton.click();
|
imageFileButton.click();
|
||||||
|
|
||||||
UiObject accept = getUiObjectByText("DONE");
|
UiObject accept = getUiObjectByText("DONE");
|
||||||
|
|
||||||
if (accept.waitForExists (uiAutoTimeout)) {
|
if (accept.waitForExists (uiAutoTimeout)) {
|
||||||
accept.click();
|
accept.click();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
logger.stop();
|
logger.stop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -272,7 +313,7 @@ public class UiAutomation extends BaseUiAutomation implements ApplaunchInterface
|
|||||||
String testTag = "text_body";
|
String testTag = "text_body";
|
||||||
ActionLogger logger = new ActionLogger(testTag, parameters);
|
ActionLogger logger = new ActionLogger(testTag, parameters);
|
||||||
|
|
||||||
UiObject composeField = mDevice.findObject(new UiSelector().textContains("Compose email") );
|
UiObject composeField = mDevice.findObject(new UiSelector().textContains("Compose email"));
|
||||||
if (!composeField.exists()){
|
if (!composeField.exists()){
|
||||||
composeField = mDevice.findObject(new UiSelector().descriptionContains("Compose email"));
|
composeField = mDevice.findObject(new UiSelector().descriptionContains("Compose email"));
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user