1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-02-21 20:38:57 +00:00

Merge pull request #445 from jimboatarm/scojac01-updated-workloads

Reworking the Gmail and GooglePlayBooks workloads to work with the la…
This commit is contained in:
setrofim 2017-08-03 10:00:19 +01:00 committed by GitHub
commit 12230da959
6 changed files with 63 additions and 32 deletions

View File

@ -39,7 +39,7 @@ class Gmail(AndroidUxPerfWorkload):
6. Enter text in the Compose field 6. Enter text in the Compose field
7. Click the Send mail button 7. Click the Send mail button
Known working APK version: 6.7.128801648 Known working APK version: 7.6.18.160170480
''' '''
parameters = [ parameters = [
@ -59,6 +59,10 @@ class Gmail(AndroidUxPerfWorkload):
# internet connection # internet connection
requires_network = True requires_network = True
def initialize(self, context):
if self.device.get_sdk_version() >= 24 and 'com.google.android.apps.photos' not in self.device.list_packages():
raise WorkloadError('gmail workload requires Google Photos to be installed for Android N onwards')
def __init__(self, device, **kwargs): def __init__(self, device, **kwargs):
super(Gmail, self).__init__(device, **kwargs) super(Gmail, self).__init__(device, **kwargs)
self.deployable_assets = [self.test_image] self.deployable_assets = [self.test_image]

View File

@ -155,44 +155,65 @@ public void runUiAutomation() throws Exception {
getUiObjectByText("Attach file", "android.widget.TextView"); getUiObjectByText("Attach file", "android.widget.TextView");
attachFile.clickAndWaitForNewWindow(uiAutoTimeout); attachFile.clickAndWaitForNewWindow(uiAutoTimeout);
UiObject waFolder = // Show Roots menu
mDevice.findObject(new UiSelector().textContains("wa-working") UiObject rootMenu =
mDevice.findObject(new UiSelector().descriptionContains("Show roots")
.className("android.widget.ImageButton"));
if (rootMenu.exists()){
rootMenu.click();
}
// Check for Photos
UiObject photos =
mDevice.findObject(new UiSelector().text("Photos")
.className("android.widget.TextView")); .className("android.widget.TextView"));
// Some devices use a FrameLayout as oppoised to a view Group so treat them differently // If Photos does not exist use the images folder
if (!waFolder.waitForExists(uiAutoTimeout)) { if (!photos.waitForExists (uiAutoTimeout)) {
UiObject rootMenu =
mDevice.findObject(new UiSelector().descriptionContains("Show roots")
.className("android.widget.ImageButton"));
// Portrait devices will roll the menu up so click the root menu icon
if (rootMenu.exists()) {
rootMenu.click();
}
UiObject imagesEntry = UiObject imagesEntry =
mDevice.findObject(new UiSelector().textContains("Images") mDevice.findObject(new UiSelector().textContains("Images")
.className("android.widget.TextView")); .className("android.widget.TextView"));
// Go to the 'Images' section
if (imagesEntry.waitForExists(uiAutoTimeout)) { if (imagesEntry.waitForExists(uiAutoTimeout)) {
imagesEntry.click(); imagesEntry.click();
} }
// Find and select the folder
selectGalleryFolder("wa-working"); selectGalleryFolder("wa-working");
}
UiObject imageFileButton = UiObject imageButton =
mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/grid") mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/grid")
.className("android.widget.GridView") .className("android.widget.Gridview")
.childSelector(new UiSelector().index(0) .childSelector(new UiSelector().index(0)
.className("android.widget.FrameLayout"))); .className("android.widget.FrameLayout")));
if (!imageFileButton.exists()){ if (!imageButton.exists()){
imageFileButton = imageButton =
mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/dir_list") mDevice.findObject(new UiSelector().resourceId("com.android.documentsui:id/dir_list")
.childSelector(new UiSelector().index(0) .childSelector(new UiSelector().index(0)
.classNameMatches("android.widget..*Layout"))); .classNameMatches("android.widget..*Layout")));
}
imageButton.click();
imageButton.waitUntilGone(uiAutoTimeout);
} else {
photos.click();
//Click wa folder image
UiObject waFolder =
mDevice.findObject(new UiSelector().textContains("wa-working")
.className("android.widget.TextView"));
if (!waFolder.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();
}
waFolder.waitForExists (uiAutoTimeout);
waFolder.click();
//Click test image
UiObject imageFileButton =
mDevice.findObject(new UiSelector().descriptionContains("Photo"));
imageFileButton.click();
UiObject accept = getUiObjectByText("DONE");
if (accept.waitForExists (uiAutoTimeout)) {
accept.click();
}
} }
imageFileButton.click();
imageFileButton.waitUntilGone(uiAutoTimeout);
logger.stop(); logger.stop();
} }

View File

@ -52,7 +52,7 @@ class Googleplaybooks(AndroidUxPerfWorkload):
Tip: Install the 'Google Opinion Rewards' app to bypass the need to enter valid Tip: Install the 'Google Opinion Rewards' app to bypass the need to enter valid
card/bank detail. card/bank detail.
Known working APK version: 3.9.37 Known working APK version: 3.13.17
''' '''
parameters = [ parameters = [

View File

@ -200,7 +200,7 @@ public void runUiAutomation() throws Exception {
mDevice.findObject(new UiSelector().resourceId(packageID + "menu_search")); mDevice.findObject(new UiSelector().resourceId(packageID + "menu_search"));
if (!search.exists()) { if (!search.exists()) {
search = search =
mDevice.findObject(new UiSelector().resourceId(packageID + "search_box_active_text_view")); mDevice.findObject(new UiSelector().resourceId(packageID + "search_box_idle_text"));
} }
search.click(); search.click();
@ -278,15 +278,21 @@ public void runUiAutomation() throws Exception {
ActionLogger logger = new ActionLogger(testTag, parameters); ActionLogger logger = new ActionLogger(testTag, parameters);
logger.start(); logger.start();
clickUiObject(BY_DESC, "Show navigation drawer"); //clickUiObject(BY_DESC, "Show navigation drawer");
// To correctly find the UiObject we need to specify the index also here // To correctly find the UiObject we need to specify the index also here
UiObject myLibrary = UiObject myLibrary =
mDevice.findObject(new UiSelector().className("android.widget.TextView") mDevice.findObject(new UiSelector().className("android.widget.TextView")
.textMatches(".*[lL]ibrary") .textMatches(".*[lL]ibrary")
.index(3)); .index(3));
myLibrary.clickAndWaitForNewWindow(uiAutoTimeout); if (myLibrary.exists()) {
logger.stop(); myLibrary.clickAndWaitForNewWindow(uiAutoTimeout);
} } else if (!myLibrary.exists()) {
UiObject library =
getUiObjectByResourceId("com.google.android.apps.books:id/jump_text");
library.click();
}
logger.stop();
}
private void openBook(final String bookTitle) throws Exception { private void openBook(final String bookTitle) throws Exception {
String testTag = "open_book"; String testTag = "open_book";
@ -316,7 +322,7 @@ public void runUiAutomation() throws Exception {
} }
logger.start(); logger.start();
book.click(); book.click();
waitForPage(); waitForPage();
logger.stop(); logger.stop();
} }