diff --git a/wlauto/workloads/gmail/__init__.py b/wlauto/workloads/gmail/__init__.py index dd8b93c6..748619b9 100755 --- a/wlauto/workloads/gmail/__init__.py +++ b/wlauto/workloads/gmail/__init__.py @@ -42,6 +42,20 @@ class Gmail(AndroidUiAutoBenchmark): super(Gmail, self).__init__(device, **kwargs) self.uiauto_params['recipient'] = self.recipient + def setup(self, context): + super(Gmail, self).setup(context) + + self.camera_dir = self.device.path.join(self.device.external_storage_directory, + 'DCIM/Camera/') + + for file in os.listdir(self.dependencies_directory): + if file.endswith(".jpg"): + self.device.push_file(os.path.join(self.dependencies_directory, file), + os.path.join(self.camera_dir, file), timeout=300) + + # Force a re-index of the mediaserver cache to pick up new files + self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard') + def validate(self): super(Gmail, self).validate() self.output_file = os.path.join(self.device.working_directory, self.instrumentation_log) diff --git a/wlauto/workloads/gmail/com.arm.wlauto.uiauto.gmail.jar b/wlauto/workloads/gmail/com.arm.wlauto.uiauto.gmail.jar index 9e50ab70..783a5205 100644 Binary files a/wlauto/workloads/gmail/com.arm.wlauto.uiauto.gmail.jar and b/wlauto/workloads/gmail/com.arm.wlauto.uiauto.gmail.jar differ diff --git a/wlauto/workloads/gmail/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java b/wlauto/workloads/gmail/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java index afeafcec..e3455c33 100644 --- a/wlauto/workloads/gmail/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java +++ b/wlauto/workloads/gmail/uiauto/src/com/arm/wlauto/uiauto/UiAutomation.java @@ -14,8 +14,9 @@ import com.arm.wlauto.uiauto.UxPerfUiAutomation; import java.io.BufferedWriter; import java.io.FileWriter; -import java.util.LinkedHashMap; +import java.util.concurrent.TimeUnit; import java.util.Iterator; +import java.util.LinkedHashMap; import java.util.Map; import java.util.Map.Entry; @@ -24,6 +25,7 @@ public class UiAutomation extends UxPerfUiAutomation { public static String TAG = "uxperf_gmail"; private Bundle parameters; + private long networkTimeout = TimeUnit.SECONDS.toMillis(20); private LinkedHashMap timingResults = new LinkedHashMap(); public void runUiAutomation() throws Exception { @@ -38,6 +40,7 @@ public class UiAutomation extends UxPerfUiAutomation { setToField(); setSubjectField(); setComposeField(); + attachFiles(); clickSendButton(); result.end(); @@ -53,6 +56,12 @@ public class UiAutomation extends UxPerfUiAutomation { gotItBox.clickAndWaitForNewWindow(); UiObject takeMeToBox = getUiObjectByText("Take me to Gmail", "android.widget.TextView"); takeMeToBox.clickAndWaitForNewWindow(); + UiObject converationView = new UiObject(new UiSelector() + .resourceId("com.google.android.gm:id/conversation_list_view") + .className("android.widget.ListView")); + if (!converationView.waitForExists(networkTimeout)) { + throw new UiObjectNotFoundException("Could not find \"converationView\"."); + }; } public void clickNewMail() throws Exception { @@ -104,6 +113,36 @@ public class UiAutomation extends UxPerfUiAutomation { timingResults.put("Send", result); } + public void attachFiles() throws Exception { + Timer result = new Timer(); + UiObject attachIcon = getUiObjectByResourceId("com.google.android.gm:id/add_attachment", + "android.widget.TextView"); + + String [] imageFiles = {"1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"}; + + result.start(); + + for ( int i=0; i < imageFiles.length; i++) { + attachIcon.clickAndWaitForNewWindow(timeout); + UiObject attachFile = getUiObjectByText("Attach file", "android.widget.TextView"); + attachFile.clickAndWaitForNewWindow(timeout); + UiObject imagesEntry = getUiObjectByText("Images", "android.widget.TextView"); + imagesEntry.clickAndWaitForNewWindow(timeout); + UiObject listView = new UiObject(new UiSelector().textContains("List view") + .className("android.webkit.WebView")); + if (listView.exists()) { + listView.clickAndWaitForNewWindow(timeout); + } + UiObject cameraEntry = getUiObjectByText("Camera", "android.widget.TextView"); + cameraEntry.clickAndWaitForNewWindow(timeout); + UiObject oneJpg = getUiObjectByText(imageFiles[i], "android.widget.TextView"); + oneJpg.clickAndWaitForNewWindow(timeout); + } + result.end(); + timingResults.put("AttachFiles", result); + } + + private void writeResultsToFile(LinkedHashMap timingResults, String file) throws Exception { // Write out the key/value pairs to the instrumentation log file FileWriter fstream = new FileWriter(file);