1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-04-13 14:20:50 +01:00

Extended BaseUiAutomation and UxPerfUiAutomation

Moved common functionality to base classes for code reuse. Refactored
googlephotos, reader and gmail workloads to take advantage of the new
base class methods and removed total test time metric.

New methods for BaseUiAutomation:
uiDeviceVertPinchIn, uiDeviceVertPinchOut

New methods for UxPerfUiAutomation:
uiObjectVertPinchTest, writeResultsToFile, startDumpsysSurfaceFlinger,
startDumpsysSurfaceFlinger, startDumpsysGfxInfo, stopDumpsysGfxInfo

New class for UxPerfUiAutomation:
GestureTestParams
This commit is contained in:
John Richardson 2016-05-04 11:10:07 +01:00
parent c2a68074be
commit 31cf06b62a
9 changed files with 167 additions and 257 deletions

View File

@ -22,13 +22,13 @@ import java.io.InputStreamReader;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.TimeUnit;
import android.app.Activity;
import android.os.Bundle;
import android.graphics.Point;
import android.graphics.Rect;
// Import the uiautomator libraries
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
@ -207,4 +207,48 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
getDisplayCentreHeight(),
steps);
}
public void uiDeviceVertPinchIn(UiObject view, int steps, int percent) throws Exception {
final int FINGER_TOUCH_HALF_WIDTH = 20;
// Make value between 1 and 100
percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
Rect rect = view.getVisibleBounds();
if (rect.width() <= FINGER_TOUCH_HALF_WIDTH * 2)
throw new IllegalStateException("Object width is too small for operation");
// Start at the top-center and bottom-center of the control
Point startPoint1 = new Point(rect.centerX(), rect.centerY() + (int) ((rect.height() / 2) * percentage));
Point startPoint2 = new Point(rect.centerX(), rect.centerY() - (int) ((rect.height() / 2) * percentage));
// End at the same point at the center of the control
Point endPoint1 = new Point(rect.centerX(), rect.centerY() + FINGER_TOUCH_HALF_WIDTH);
Point endPoint2 = new Point(rect.centerX(), rect.centerY() - FINGER_TOUCH_HALF_WIDTH);
view.performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
public void uiDeviceVertPinchOut(UiObject view, int steps, int percent) throws Exception {
final int FINGER_TOUCH_HALF_WIDTH = 20;
// Make value between 1 and 100
percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
Rect rect = view.getVisibleBounds();
if (rect.width() <= FINGER_TOUCH_HALF_WIDTH * 2)
throw new IllegalStateException("Object width is too small for operation");
// Start from the same point at the center of the control
Point startPoint1 = new Point(rect.centerX(), rect.centerY() + FINGER_TOUCH_HALF_WIDTH);
Point startPoint2 = new Point(rect.centerX(), rect.centerY() - FINGER_TOUCH_HALF_WIDTH);
// End at the top-center and bottom-center of the control
Point endPoint1 = new Point(rect.centerX(), rect.centerY() + (int) ((rect.height() / 2) * percentage));
Point endPoint2 = new Point(rect.centerX(), rect.centerY() - (int) ((rect.height() / 2) * percentage));
view.performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
}

View File

@ -17,6 +17,7 @@ package com.arm.wlauto.uiauto;
import android.os.Build;
import android.os.SystemClock;
import android.os.Bundle;
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
@ -26,6 +27,7 @@ import com.android.uiautomator.core.UiSelector;
import com.arm.wlauto.uiauto.BaseUiAutomation;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.File;
import java.io.FileWriter;
import java.io.InputStreamReader;
@ -34,6 +36,10 @@ import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.Arrays;
import java.util.List;
import java.util.LinkedHashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Map.Entry;
public class UxPerfUiAutomation extends BaseUiAutomation {
@ -209,4 +215,85 @@ public class UxPerfUiAutomation extends BaseUiAutomation {
results.end();
return results;
}
public Timer uiObjectVertPinchTest(UiObject view, PinchType direction,
int steps, int percent) throws Exception {
Timer results = new Timer();
results.start();
if (direction.equals(PinchType.IN)) {
uiDeviceVertPinchIn(view, steps, percent);
} else if (direction.equals(PinchType.OUT)) {
uiDeviceVertPinchOut(view, steps, percent);
}
results.end();
return results;
}
public class GestureTestParams {
public GestureType gestureType;
public Direction gestureDirection;
public PinchType pinchType;
public int percent;
public int steps;
public GestureTestParams(GestureType gesture, Direction direction, int steps) {
this.gestureType = gesture;
this.gestureDirection = direction;
this.pinchType = PinchType.NULL;
this.steps = steps;
this.percent = 0;
}
public GestureTestParams(GestureType gesture, PinchType pinchType, int steps, int percent) {
this.gestureType = gesture;
this.gestureDirection = Direction.NULL;
this.pinchType = pinchType;
this.steps = steps;
this.percent = percent;
}
}
public void writeResultsToFile(LinkedHashMap timingResults, String file) throws Exception {
// Write out the key/value pairs to the instrumentation log file
FileWriter fstream = new FileWriter(file);
BufferedWriter out = new BufferedWriter(fstream);
Iterator<Entry<String, Timer>> it = timingResults.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Timer> pairs = it.next();
Timer results = pairs.getValue();
long start = results.getStart();
long finish = results.getFinish();
long duration = results.getDuration();
out.write(String.format(pairs .getKey() + " " + start + " " + finish + " " + duration + "\n"));
}
out.close();
}
public void startDumpsysSurfaceFlinger(Bundle parameters, String view) {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysSurfaceFlinger(parameters.getString("package"), view);
}
}
public void stopDumpsysSurfaceFlinger(Bundle parameters, String view,
String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysSurfaceFlinger(parameters.getString("package"), view, out_file);
}
}
public void startDumpsysGfxInfo(Bundle parameters) {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysGfxInfo(parameters.getString("package"));
}
}
public void stopDumpsysGfxInfo(Bundle parameters, String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysGfxInfo(parameters.getString("package"), out_file);
}
}
}

View File

@ -1,24 +1,16 @@
package com.arm.wlauto.uiauto.gmail;
import android.os.Bundle;
import android.os.SystemClock;
// Import the uiautomator libraries
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
import java.io.BufferedWriter;
import java.io.FileWriter;
import java.util.concurrent.TimeUnit;
import java.util.Iterator;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.Map.Entry;
public class UiAutomation extends UxPerfUiAutomation {
@ -55,7 +47,7 @@ public class UiAutomation extends UxPerfUiAutomation {
.className("android.widget.ListView"));
if (!converationView.waitForExists(networkTimeout)) {
throw new UiObjectNotFoundException("Could not find \"converationView\".");
};
}
}
public void clickNewMail() throws Exception {
@ -112,9 +104,9 @@ public class UiAutomation extends UxPerfUiAutomation {
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"};
String[] imageFiles = {"1.jpg", "2.jpg", "3.jpg", "4.jpg", "5.jpg"};
for ( int i=0; i < imageFiles.length; i++) {
for ( int i = 0; i < imageFiles.length; i++) {
result.start();
clickUiObject(attachIcon, timeout);
@ -174,21 +166,4 @@ public class UiAutomation extends UxPerfUiAutomation {
timingResults.put(String.format("AttachFiles" + "_" + file), 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);
BufferedWriter out = new BufferedWriter(fstream);
Iterator<Entry<String, Timer>> it = timingResults.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Timer> pairs = it.next();
Timer results = pairs.getValue();
long start = results.getStart();
long finish = results.getFinish();
long duration = results.getDuration();
out.write(String.format(pairs.getKey() + " " + start + " " + finish + " " + duration + "\n"));
}
out.close();
}
}

View File

@ -39,8 +39,6 @@ class Googlephotos(AndroidUiAutoBenchmark):
def __init__(self, device, **kwargs):
super(Googlephotos, self).__init__(device, **kwargs)
self.output_file = os.path.join(self.device.working_directory, self.instrumentation_log)
self.camera_dir = self.device.path.join(self.device.external_storage_directory,
'DCIM/Camera/')
def validate(self):
super(Googlephotos, self).validate()
@ -56,7 +54,7 @@ class Googlephotos(AndroidUiAutoBenchmark):
wa_file = ''.join([self.file_prefix, entry])
if entry.endswith(".jpg"):
self.device.push_file(os.path.join(self.dependencies_directory, entry),
os.path.join(self.camera_dir, wa_file),
os.path.join(self.device.working_directory, wa_file),
timeout=300)
# Force a re-index of the mediaserver cache to pick up new files
@ -91,9 +89,8 @@ class Googlephotos(AndroidUiAutoBenchmark):
context.output_directory)
self.device.delete_file(os.path.join(self.device.working_directory, entry))
for entry in self.device.listdir(self.camera_dir):
if entry.startswith(self.file_prefix) and entry.endswith(".jpg"):
self.device.delete_file(os.path.join(self.camera_dir, entry))
self.device.delete_file(os.path.join(self.device.working_directory, entry))
# Force a re-index of the mediaserver cache to removed cached files
self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard')

View File

@ -1,9 +1,9 @@
#!/bin/bash
class_dir=bin/classes/com/arm/wlauto/uiauto
base_class=`python -c "import os, wlauto; print os.path.join(os.path.dirname(wlauto.__file__), 'common', 'android', '*.class')"`
base_classes=`python -c "import os, wlauto; print os.path.join(os.path.dirname(wlauto.__file__), 'common', 'android', '*.class')"`
mkdir -p $class_dir
cp $base_class $class_dir
cp $base_classes $class_dir
ant build

View File

@ -11,4 +11,4 @@
#proguard.config=${sdk.dir}/tools/proguard/proguard-android.txt:proguard-project.txt
# Project target.
target=android-23
target=android-18

View File

@ -1,8 +1,6 @@
package com.arm.wlauto.uiauto.googlephotos;
import android.os.Bundle;
import android.graphics.Point;
import android.graphics.Rect;
// Import the uiautomator libraries
import com.android.uiautomator.core.UiObject;
@ -11,9 +9,6 @@ import com.android.uiautomator.core.UiSelector;
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.util.concurrent.TimeUnit;
import java.util.LinkedHashMap;
import java.util.Iterator;
@ -25,21 +20,16 @@ public class UiAutomation extends UxPerfUiAutomation {
public static String TAG = "uxperf_googlephotos";
public Bundle parameters;
private long viewTimeout = TimeUnit.SECONDS.toMillis(20);
private long viewTimeout = TimeUnit.SECONDS.toMillis(10);
private LinkedHashMap<String, Timer> timingResults = new LinkedHashMap<String, Timer>();
public void runUiAutomation() throws Exception {
Timer result = new Timer();
result.start();
parameters = getParams();
dismissWelcomeView();
gesturesTest();
editPhotoTest();
result.end();
timingResults.put("total", result);
writeResultsToFile(timingResults, parameters.getString("output_file"));
}
@ -50,10 +40,10 @@ public class UiAutomation extends UxPerfUiAutomation {
sleep(3); // Pause while splash screen loads
UiObject getStarteddButton =
UiObject getStartedButton =
getUiObjectByResourceId("com.google.android.apps.photos:id/get_started",
"android.widget.Button");
getStarteddButton.clickAndWaitForNewWindow();
getStartedButton.clickAndWaitForNewWindow();
UiObject welcomeButton =
getUiObjectByResourceId("com.google.android.apps.photos:id/name",
@ -79,7 +69,7 @@ public class UiAutomation extends UxPerfUiAutomation {
nextButton.clickAndWaitForNewWindow();
}
private void gesturesTest () throws Exception {
private void gesturesTest() throws Exception {
String testTag = "gestures";
// Perform a range of swipe tests while browsing photo gallery
@ -112,10 +102,10 @@ public class UiAutomation extends UxPerfUiAutomation {
if (!view.waitForExists(viewTimeout)) {
throw new UiObjectNotFoundException("Could not find \"photo view\".");
};
}
startDumpsysGfxInfo();
startDumpsysSurfaceFlinger(viewName);
startDumpsysGfxInfo(parameters);
startDumpsysSurfaceFlinger(parameters, viewName);
Timer results = new Timer();
@ -133,8 +123,8 @@ public class UiAutomation extends UxPerfUiAutomation {
break;
}
stopDumpsysSurfaceFlinger(viewName, surfFlingerlogName);
stopDumpsysGfxInfo(gfxInfologName);
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
stopDumpsysGfxInfo(parameters, gfxInfologName);
timingResults.put(runName, results);
}
@ -172,9 +162,9 @@ public class UiAutomation extends UxPerfUiAutomation {
timingResults.put(testTag, result);
}
// Helper to click on an individual photographs based on index in Camera gallery.
private void selectPhoto(int index) throws Exception {
UiObject cameraHeading = new UiObject(new UiSelector().text("Camera"));
// Helper to click on an individual photographs based on index in wa-working gallery.
private void selectPhoto(final int index) throws Exception {
UiObject cameraHeading = new UiObject(new UiSelector().text("wa-working"));
cameraHeading.clickAndWaitForNewWindow();
UiObject photo =
@ -183,109 +173,4 @@ public class UiAutomation extends UxPerfUiAutomation {
.index(index)));
photo.click();
}
// Helper for testing zoom facility. NOTE: the built in UiObject methods
// pinchIn() and pinchOut() do not zoom appropriately for this application.
private Timer uiObjectVertPinchTest(
UiObject view, PinchType direction,
int steps, int percent) throws Exception {
Timer results = new Timer();
results.start();
final int FINGER_TOUCH_HALF_WIDTH = 20;
// make value between 1 and 100
percent = (percent < 0) ? 1 : (percent > 100) ? 100 : percent;
float percentage = percent / 100f;
Rect rect = view.getVisibleBounds();
if (rect.width() <= FINGER_TOUCH_HALF_WIDTH * 2)
throw new IllegalStateException("Object width is too small for operation");
// start from the same point at the center of the control
Point startPoint1 = new Point(rect.centerX(), rect.centerY() + FINGER_TOUCH_HALF_WIDTH);
Point startPoint2 = new Point(rect.centerX(), rect.centerY() - FINGER_TOUCH_HALF_WIDTH);
// End at the top-center and bottom-center of the control
Point endPoint1 = new Point(rect.centerX(), rect.centerY() + (int) ((rect.height() / 2) * percentage));
Point endPoint2 = new Point(rect.centerX(), rect.centerY() - (int) ((rect.height() / 2) * percentage));
if (direction.equals(PinchType.IN)) {
view.performTwoPointerGesture(endPoint1, endPoint2, startPoint1, startPoint2, steps);
} else if (direction.equals(PinchType.OUT)) {
view.performTwoPointerGesture(startPoint1, startPoint2, endPoint1, endPoint2, steps);
}
results.end();
return results;
}
private class GestureTestParams {
GestureType gestureType;
Direction gestureDirection;
PinchType pinchType;
private int percent;
private int steps;
GestureTestParams(GestureType gesture, Direction direction, int steps) {
this.gestureType = gesture;
this.gestureDirection = direction;
this.pinchType = PinchType.NULL;
this.steps = steps;
this.percent = 0;
}
GestureTestParams(GestureType gesture, PinchType pinchType, int steps, int percent) {
this.gestureType = gesture;
this.gestureDirection = Direction.NULL;
this.pinchType = pinchType;
this.steps = steps;
this.percent = percent;
}
}
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);
BufferedWriter out = new BufferedWriter(fstream);
Iterator<Entry<String, Timer>> it = timingResults.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Timer> pairs = it.next();
Timer results = pairs.getValue();
long start = results.getStart();
long finish = results.getFinish();
long duration = results.getDuration();
out.write(String.format(pairs .getKey() + " " + start + " " + finish + " " + duration + "\n"));
}
out.close();
}
private void startDumpsysSurfaceFlinger(String view) {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysSurfaceFlinger(parameters.getString("package"), view);
}
}
private void stopDumpsysSurfaceFlinger(String view, String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysSurfaceFlinger(parameters.getString("package"), view, out_file);
}
}
private void startDumpsysGfxInfo() {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysGfxInfo(parameters.getString("package"));
}
}
private void stopDumpsysGfxInfo(String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysGfxInfo(parameters.getString("package"), out_file);
}
}
}

View File

@ -7,16 +7,10 @@ import android.os.SystemClock;
// Import the uiautomator libraries
import com.android.uiautomator.core.UiObject;
import com.android.uiautomator.core.UiObjectNotFoundException;
import com.android.uiautomator.core.UiScrollable;
import com.android.uiautomator.core.UiSelector;
import com.android.uiautomator.core.UiCollection;
import com.android.uiautomator.testrunner.UiAutomatorTestCase;
import com.arm.wlauto.uiauto.UxPerfUiAutomation;
import java.io.File;
import java.io.FileWriter;
import java.io.BufferedWriter;
import java.util.concurrent.TimeUnit;
import java.util.Iterator;
import java.util.LinkedHashMap;
@ -33,8 +27,6 @@ public class UiAutomation extends UxPerfUiAutomation {
private LinkedHashMap<String, Timer> timingResults = new LinkedHashMap<String, Timer>();
public void runUiAutomation() throws Exception {
Timer result = new Timer();
result.start();
parameters = getParams();
dismissWelcomeView();
@ -45,12 +37,9 @@ public class UiAutomation extends UxPerfUiAutomation {
gesturesTest("Getting Started.pdf");
String [] searchStrings = {"Glossary", "cortex"};
String[] searchStrings = {"Glossary", "cortex"};
searchPdfTest("cortex_m4", searchStrings);
result.end();
timingResults.put("Total", result);
writeResultsToFile(timingResults, parameters.getString("output_file"));
}
@ -73,7 +62,7 @@ public class UiAutomation extends UxPerfUiAutomation {
do {
i += 10;
tapDisplay(webViewCoords.centerX(), webViewCoords.centerY() + i);
} while ( welcomeView.exists() || i < webViewCoords.top );
} while (welcomeView.exists() || i < webViewCoords.top);
}
private void signInOnline(Bundle parameters) throws Exception {
@ -139,10 +128,10 @@ public class UiAutomation extends UxPerfUiAutomation {
.className("android.widget.Button"));
if (allowButton.waitForExists(timeout)) {
allowButton.clickAndWaitForNewWindow(timeout);
};
}
}
private void openFile(String filename) throws Exception {
private void openFile(final String filename) throws Exception {
String TestTag = "openfile";
@ -184,7 +173,7 @@ public class UiAutomation extends UxPerfUiAutomation {
return result;
}
private Timer searchFileList(String searchText) throws Exception {
private Timer searchFileList(final String searchText) throws Exception {
// Enter search text into the file searchBox. This will automatically filter the list.
UiObject searchBox = getUiObjectByResourceId("android:id/search_src_text",
"android.widget.EditText");
@ -196,7 +185,7 @@ public class UiAutomation extends UxPerfUiAutomation {
return result;
}
private Timer openFileFromList(String file) throws Exception {
private Timer openFileFromList(final String file) throws Exception {
// Open a file from a file list view by searching for UiObjects containing the doc title.
UiObject fileObject = getUiObjectByText(file, "android.widget.TextView");
Timer result = new Timer();
@ -212,31 +201,7 @@ public class UiAutomation extends UxPerfUiAutomation {
return result;
}
private class GestureTestParams {
GestureType gestureType;
Direction gestureDirection;
PinchType pinchType;
int percent;
int steps;
GestureTestParams(GestureType gesture, Direction direction, int steps) {
this.gestureType = gesture;
this.gestureDirection = direction;
this.pinchType = PinchType.NULL;
this.steps = steps;
this.percent = 0;
}
GestureTestParams(GestureType gesture, PinchType pinchType, int steps, int percent) {
this.gestureType = gesture;
this.gestureDirection = Direction.NULL;
this.pinchType = pinchType;
this.steps = steps;
this.percent = percent;
}
}
private void gesturesTest (String filename) throws Exception {
private void gesturesTest(final String filename) throws Exception {
String TestTag = "gestures";
@ -268,8 +233,8 @@ public class UiAutomation extends UxPerfUiAutomation {
UiObject view = new UiObject(new UiSelector().resourceId("com.adobe.reader:id/viewPager"));
startDumpsysGfxInfo();
startDumpsysSurfaceFlinger(viewName);
startDumpsysGfxInfo(parameters);
startDumpsysSurfaceFlinger(parameters, viewName);
Timer results = new Timer();
@ -287,8 +252,8 @@ public class UiAutomation extends UxPerfUiAutomation {
break;
}
stopDumpsysSurfaceFlinger(viewName, surfFlingerlogName);
stopDumpsysGfxInfo(gfxInfologName);
stopDumpsysSurfaceFlinger(parameters, viewName, surfFlingerlogName);
stopDumpsysGfxInfo(parameters, gfxInfologName);
timingResults.put(runName, results);
}
@ -296,7 +261,7 @@ public class UiAutomation extends UxPerfUiAutomation {
exitDocument();
}
private void searchPdfTest (String filename, String [] searchStrings) throws Exception {
private void searchPdfTest(final String filename, final String[] searchStrings) throws Exception {
String TestTag = "search";
@ -305,7 +270,7 @@ public class UiAutomation extends UxPerfUiAutomation {
// Get the page view for the opened document which we can use for pinch actions
UiObject pageView = getUiObjectByResourceId("com.adobe.reader:id/pageView",
"android.widget.RelativeLayout");
for ( int i=0; i < searchStrings.length; i++) {
for (int i = 0; i < searchStrings.length; i++) {
timingResults.put(String.format(TestTag + "_" + i),
searchTest(searchStrings[i]));
}
@ -313,7 +278,7 @@ public class UiAutomation extends UxPerfUiAutomation {
exitDocument();
}
private Timer searchTest(String searchText) throws Exception {
private Timer searchTest(final String searchText) throws Exception {
// Click on the search button icon and enter text in the box. This closes the keyboad
// so click the box again and press Enter to start the search.
UiObject searchButton = getUiObjectByResourceId("com.adobe.reader:id/document_view_search_icon",
@ -356,47 +321,4 @@ public class UiAutomation extends UxPerfUiAutomation {
UiObject upButton = getUiObjectByResourceId("android:id/up", "android.widget.ImageView" );
upButton.clickAndWaitForNewWindow();
}
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);
BufferedWriter out = new BufferedWriter(fstream);
Iterator<Entry<String, Timer>> it = timingResults.entrySet().iterator();
while (it.hasNext()) {
Map.Entry<String, Timer> pairs = it.next();
Timer results = pairs.getValue();
long start = results.getStart();
long finish = results.getFinish();
long duration = results.getDuration();
out.write(String.format(pairs.getKey() + " " + start + " " + finish + " " + duration + "\n"));
}
out.close();
}
private void startDumpsysSurfaceFlinger(String view) {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysSurfaceFlinger(parameters.getString("package"), view);
}
}
private void stopDumpsysSurfaceFlinger(String view, String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysSurfaceFlinger(parameters.getString("package"), view, out_file);
}
}
private void startDumpsysGfxInfo() {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
initDumpsysGfxInfo(parameters.getString("package"));
}
}
private void stopDumpsysGfxInfo(String filename) throws Exception {
if (Boolean.parseBoolean(parameters.getString("dumpsys_enabled"))) {
File out_file = new File(parameters.getString("output_dir"), filename);
exitDumpsysGfxInfo(parameters.getString("package"), out_file);
}
}
}