mirror of
				https://github.com/ARM-software/workload-automation.git
				synced 2025-11-04 09:02:12 +00:00 
			
		
		
		
	Update Gmail workload to attached images to sample email
Adds 5 image files to the email before sending.
This commit is contained in:
		@@ -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)
 | 
			
		||||
 
 | 
			
		||||
										
											Binary file not shown.
										
									
								
							@@ -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<String, Timer> timingResults = new LinkedHashMap<String, Timer>();
 | 
			
		||||
 | 
			
		||||
    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);
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user