mirror of
https://github.com/ARM-software/workload-automation.git
synced 2025-03-21 01:59:13 +00:00
Update test for file from storage
- generalised clickView method - fix workload parameter names - delete file from previous run if they exist
This commit is contained in:
parent
fbc9fe226c
commit
ac07c359fc
@ -35,6 +35,7 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
|||||||
|
|
||||||
# Views for FPS instrumentation
|
# Views for FPS instrumentation
|
||||||
view = [
|
view = [
|
||||||
|
package + '/com.qo.android.quickpoint.Quickpoint',
|
||||||
package + '/com.google.android.apps.docs.app.DocListActivity',
|
package + '/com.google.android.apps.docs.app.DocListActivity',
|
||||||
package + '/com.google.android.apps.docs.welcome.warmwelcome.TrackingWelcomeActivity',
|
package + '/com.google.android.apps.docs.welcome.warmwelcome.TrackingWelcomeActivity',
|
||||||
package + '/com.google.android.apps.docs.app.NewMainProxyActivity',
|
package + '/com.google.android.apps.docs.app.NewMainProxyActivity',
|
||||||
@ -46,18 +47,17 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
|||||||
If ``True``, dumpsys captures will be carried out during the test run.
|
If ``True``, dumpsys captures will be carried out during the test run.
|
||||||
The output is piped to log files which are then pulled from the phone.
|
The output is piped to log files which are then pulled from the phone.
|
||||||
'''),
|
'''),
|
||||||
# Parameter('local_files', kind=list_of_strings, default=['Slides_Album.pptx', 'Slides_Pitch.pptx'],
|
|
||||||
Parameter('local_files', kind=list_of_strings,
|
Parameter('local_files', kind=list_of_strings,
|
||||||
description='''
|
description='''
|
||||||
If ``True``, the workload will push PowerPoint files to be used for testing on
|
If specified, the workload will push the PowerPoint files to be used for
|
||||||
the device. Otherwise, the files will be created from template inside the app.
|
testing on the device. Otherwise, a file will be created inside the app.
|
||||||
'''),
|
'''),
|
||||||
]
|
]
|
||||||
|
|
||||||
instrumentation_log = '{}_instrumentation.log'.format(name)
|
instrumentation_log = '{}_instrumentation.log'.format(name)
|
||||||
file_prefix = 'wa_test_'
|
file_prefix = 'wa_test_'
|
||||||
|
device_dir = '/sdcard/Download'
|
||||||
local_dir = '.' # self.dependencies_directory
|
local_dir = '.' # self.dependencies_directory
|
||||||
device_dir = '/sdcard/Download' # self.device.working_directory
|
|
||||||
|
|
||||||
def __init__(self, device, **kwargs):
|
def __init__(self, device, **kwargs):
|
||||||
super(GoogleSlides, self).__init__(device, **kwargs)
|
super(GoogleSlides, self).__init__(device, **kwargs)
|
||||||
@ -71,7 +71,8 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
|||||||
self.uiauto_params['output_dir'] = self.device.working_directory
|
self.uiauto_params['output_dir'] = self.device.working_directory
|
||||||
self.uiauto_params['results_file'] = self.output_file
|
self.uiauto_params['results_file'] = self.output_file
|
||||||
if self.local_files:
|
if self.local_files:
|
||||||
self.uiauto_params['local_files'] = '::'.join(self.local_files)
|
wa_files = [self.wa_filename(f) for f in self.local_files]
|
||||||
|
self.uiauto_params['local_files'] = '::'.join(wa_files)
|
||||||
|
|
||||||
def initialize(self, context):
|
def initialize(self, context):
|
||||||
log_method(self, 'initialize')
|
log_method(self, 'initialize')
|
||||||
@ -79,10 +80,9 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
|||||||
if self.local_files:
|
if self.local_files:
|
||||||
# push local PPT files
|
# push local PPT files
|
||||||
for entry in os.listdir(self.local_dir):
|
for entry in os.listdir(self.local_dir):
|
||||||
wa_file = self.file_prefix + entry
|
|
||||||
if entry.endswith('.pptx'):
|
if entry.endswith('.pptx'):
|
||||||
self.device.push_file(path.join(self.local_dir, entry),
|
self.device.push_file(path.join(self.local_dir, entry),
|
||||||
path.join(self.device_dir, wa_file),
|
path.join(self.device_dir, self.wa_filename(entry)),
|
||||||
timeout=60)
|
timeout=60)
|
||||||
# Force a re-index of the mediaserver cache to pick up new files
|
# 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')
|
# self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard')
|
||||||
@ -112,12 +112,14 @@ class GoogleSlides(AndroidUiAutoBenchmark):
|
|||||||
if self.local_files:
|
if self.local_files:
|
||||||
# delete pushed PPT files
|
# delete pushed PPT files
|
||||||
for entry in os.listdir(self.local_dir):
|
for entry in os.listdir(self.local_dir):
|
||||||
wa_file = self.file_prefix + entry
|
|
||||||
if entry.endswith('.pptx'):
|
if entry.endswith('.pptx'):
|
||||||
self.device.delete_file(path.join(self.device_dir, wa_file))
|
self.device.delete_file(path.join(self.device_dir, self.wa_filename(entry)))
|
||||||
# Force a re-index of the mediaserver cache to pick up new files
|
# 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')
|
# self.device.execute('am broadcast -a android.intent.action.MEDIA_MOUNTED -d file:///sdcard')
|
||||||
|
|
||||||
|
def wa_filename(self, filename):
|
||||||
|
return self.file_prefix + filename
|
||||||
|
|
||||||
def get_metrics(self, context):
|
def get_metrics(self, context):
|
||||||
self.device.pull_file(self.output_file, context.output_directory)
|
self.device.pull_file(self.output_file, context.output_directory)
|
||||||
metrics_file = path.join(context.output_directory, self.instrumentation_log)
|
metrics_file = path.join(context.output_directory, self.instrumentation_log)
|
||||||
|
Binary file not shown.
@ -52,6 +52,8 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
public static final int BY_TEXT = 2;
|
public static final int BY_TEXT = 2;
|
||||||
public static final int BY_DESC = 3;
|
public static final int BY_DESC = 3;
|
||||||
|
|
||||||
|
public static final int ONE_SECOND_IN_MS = 1000;
|
||||||
|
|
||||||
public static final String DOC_FILENAME = "UX Perf Slides";
|
public static final String DOC_FILENAME = "UX Perf Slides";
|
||||||
|
|
||||||
public static final String DOCUMENTATION_WORKLOADS =
|
public static final String DOCUMENTATION_WORKLOADS =
|
||||||
@ -93,9 +95,9 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
skipWelcomeScreen();
|
skipWelcomeScreen();
|
||||||
enablePowerpointCompat();
|
enablePowerpointCompat();
|
||||||
if (useLocalFiles) {
|
if (useLocalFiles) {
|
||||||
testEditFileFromStorage(documents[0]);
|
testSlideshowFromStorage(documents[0]);
|
||||||
} else {
|
} else {
|
||||||
testEditNewSlidesDoc(DOC_FILENAME);
|
testEditNewSlidesDocument(DOC_FILENAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (false) { // TODO currently unused
|
if (false) { // TODO currently unused
|
||||||
@ -104,38 +106,39 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected void skipWelcomeScreen() throws Exception {
|
protected void skipWelcomeScreen() throws Exception {
|
||||||
UiObject skipButton = getUiObjectByText("Skip", CLASS_BUTTON);
|
clickView(BY_TEXT, "Skip", true);
|
||||||
skipButton.clickAndWaitForNewWindow();
|
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void enablePowerpointCompat() throws Exception {
|
protected void enablePowerpointCompat() throws Exception {
|
||||||
uiDeviceEdgeSwipeFromLeft(10);
|
uiDeviceEdgeSwipeFromLeft(10);
|
||||||
UiObject settings = getUiObjectByText("Settings", CLASS_TEXT_VIEW);
|
clickView(BY_TEXT, "Settings", true);
|
||||||
settings.clickAndWaitForNewWindow();
|
clickView(BY_TEXT, "Create PowerPoint");
|
||||||
UiObject checkboxRow = getUiObjectByText("Create PowerPoint", CLASS_TEXT_VIEW);
|
|
||||||
checkboxRow.click();
|
|
||||||
getUiDevice().pressBack();
|
getUiDevice().pressBack();
|
||||||
sleep(1);
|
sleep(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testEditFileFromStorage(String document) throws Exception {
|
protected void testSlideshowFromStorage(String document) throws Exception {
|
||||||
UiObject openButton = getUiObjectByDescription("Open presentation", CLASS_TEXT_VIEW);
|
// Sometimes docs deleted in __init__.py falsely appear on the app's home
|
||||||
openButton.click();
|
// For robustness, it's nice to remove these placeholders
|
||||||
openButton = getUiObjectByText("Device storage", CLASS_TEXT_VIEW);
|
// However, the test should not crash because of it, so a silent catch is used
|
||||||
openButton.clickAndWaitForNewWindow();
|
UiObject docView = new UiObject(new UiSelector().textContains(document));
|
||||||
|
if (docView.waitForExists(ONE_SECOND_IN_MS)) {
|
||||||
UiObject selectDoc = getUiObjectByText(document, CLASS_TEXT_VIEW);
|
try {
|
||||||
selectDoc.click();
|
deleteDocument(document);
|
||||||
openButton = getUiObjectByText("Open", CLASS_BUTTON);
|
} catch (Exception e) {
|
||||||
openButton.clickAndWaitForNewWindow();
|
// do nothing
|
||||||
|
}
|
||||||
sleep(1);
|
}
|
||||||
|
clickView(BY_DESC, "Open presentation");
|
||||||
|
clickView(BY_TEXT, "Device storage", true);
|
||||||
|
clickView(BY_TEXT, document);
|
||||||
|
clickView(BY_TEXT, "Open", CLASS_BUTTON, true);
|
||||||
|
sleep(5);
|
||||||
getUiDevice().pressBack();
|
getUiDevice().pressBack();
|
||||||
deleteDocument(document);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void testEditNewSlidesDoc(String docName) throws Exception {
|
protected void testEditNewSlidesDocument(String docName) throws Exception {
|
||||||
// create new file
|
// create new file
|
||||||
clickView(BY_DESC, "New presentation");
|
clickView(BY_DESC, "New presentation");
|
||||||
clickView(BY_TEXT, "New PowerPoint", true);
|
clickView(BY_TEXT, "New PowerPoint", true);
|
||||||
@ -210,17 +213,16 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
clickView(BY_TEXT, "Device");
|
clickView(BY_TEXT, "Device");
|
||||||
// Allow SD card access if requested
|
// Allow SD card access if requested
|
||||||
UiObject permissionView = new UiObject(new UiSelector().textContains("Allow Slides"));
|
UiObject permissionView = new UiObject(new UiSelector().textContains("Allow Slides"));
|
||||||
if (permissionView.waitForExists(1000)) {
|
if (permissionView.waitForExists(ONE_SECOND_IN_MS)) {
|
||||||
clickView(BY_TEXT, "Allow");
|
clickView(BY_TEXT, "Allow");
|
||||||
}
|
}
|
||||||
UiObject filename = getViewById(PACKAGE_ID + "file_name_edit_text");
|
UiObject filename = getViewById(PACKAGE_ID + "file_name_edit_text");
|
||||||
filename.clearTextField();
|
filename.clearTextField();
|
||||||
filename.setText(docName);
|
filename.setText(docName);
|
||||||
UiObject saveButton = getUiObjectByText("Save", CLASS_BUTTON);
|
clickView(BY_TEXT, "Save");
|
||||||
saveButton.click();
|
|
||||||
// Overwrite if prompted
|
// Overwrite if prompted
|
||||||
UiObject overwriteView = new UiObject(new UiSelector().textContains("already exists"));
|
UiObject overwriteView = new UiObject(new UiSelector().textContains("already exists"));
|
||||||
if (overwriteView.waitForExists(1000)) {
|
if (overwriteView.waitForExists(ONE_SECOND_IN_MS)) {
|
||||||
clickView(BY_TEXT, "Overwrite");
|
clickView(BY_TEXT, "Overwrite");
|
||||||
}
|
}
|
||||||
sleep(1);
|
sleep(1);
|
||||||
@ -240,8 +242,8 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
public void deleteDocument(String docName) throws Exception {
|
public void deleteDocument(String docName) throws Exception {
|
||||||
UiObject doc = getViewByText(docName);
|
UiObject doc = getViewByText(docName);
|
||||||
doc.longClick();
|
doc.longClick();
|
||||||
UiObject deleteButton = getUiObjectByText("Remove", CLASS_TEXT_VIEW);
|
clickView(BY_TEXT, "Remove");
|
||||||
deleteButton.click();
|
UiObject deleteButton;
|
||||||
try {
|
try {
|
||||||
deleteButton = getUiObjectByText("Remove", CLASS_BUTTON);
|
deleteButton = getUiObjectByText("Remove", CLASS_BUTTON);
|
||||||
} catch (UiObjectNotFoundException e) {
|
} catch (UiObjectNotFoundException e) {
|
||||||
@ -259,26 +261,34 @@ public class UiAutomation extends UxPerfUiAutomation {
|
|||||||
if (repeat < 1 || !view.isClickable()) return;
|
if (repeat < 1 || !view.isClickable()) return;
|
||||||
while (repeat-- > 0) {
|
while (repeat-- > 0) {
|
||||||
view.click();
|
view.click();
|
||||||
sleepMicro(10); // in order to register as separate
|
sleepMicro(100); // in order to register as separate click
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public UiObject clickView(int criteria, String matching) throws Exception {
|
public UiObject clickView(int criteria, String matching) throws Exception {
|
||||||
return clickView(criteria, matching, false);
|
return clickView(criteria, matching, null, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public UiObject clickView(int criteria, String matching, boolean wait) throws Exception {
|
public UiObject clickView(int criteria, String matching, boolean wait) throws Exception {
|
||||||
|
return clickView(criteria, matching, null, wait);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UiObject clickView(int criteria, String matching, String clazz) throws Exception {
|
||||||
|
return clickView(criteria, matching, clazz, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public UiObject clickView(int criteria, String matching, String clazz, boolean wait) throws Exception {
|
||||||
UiObject view;
|
UiObject view;
|
||||||
switch (criteria) {
|
switch (criteria) {
|
||||||
case BY_ID:
|
case BY_ID:
|
||||||
view = getViewById(matching);
|
view = clazz == null ? getViewById(matching) : getUiObjectByResourceId(matching, clazz);
|
||||||
break;
|
break;
|
||||||
case BY_DESC:
|
case BY_DESC:
|
||||||
view = getViewByDesc(matching);
|
view = clazz == null ? getViewByDesc(matching) : getUiObjectByDescription(matching, clazz);
|
||||||
break;
|
break;
|
||||||
case BY_TEXT:
|
case BY_TEXT:
|
||||||
default:
|
default:
|
||||||
view = getViewByText(matching);
|
view = clazz == null ? getViewByText(matching) : getUiObjectByText(matching, clazz);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (wait) {
|
if (wait) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user