1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-21 01:59:13 +00:00

Simplify test methods

This commit is contained in:
muendelezaji 2016-05-19 14:12:37 +01:00 committed by muendelezaji
parent a04829de25
commit fbc9fe226c
2 changed files with 55 additions and 80 deletions

View File

@ -48,16 +48,12 @@ public class UiAutomation extends UxPerfUiAutomation {
public static final String CLASS_IMAGE_BUTTON = "android.widget.ImageButton"; public static final String CLASS_IMAGE_BUTTON = "android.widget.ImageButton";
public static final String CLASS_TABLE_ROW = "android.widget.TableRow"; public static final String CLASS_TABLE_ROW = "android.widget.TableRow";
public static final int DOCTYPE_TEMPLATE = 1;
public static final int DOCTYPE_PPT = 2;
public static final int DOCTYPE_SLIDES = 3;
public static final String DOC_FILENAME = "UX Perf Slides";
// public static final String DOC_FILENAME = "Untitled Presentation";
public static final int BY_ID = 1; public static final int BY_ID = 1;
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 String DOC_FILENAME = "UX Perf Slides";
public static final String DOCUMENTATION_WORKLOADS = public static final String DOCUMENTATION_WORKLOADS =
"class Workload(Extension):\n\tname = None\n\tdef init_resources(self, context):\n\t\tpass\n" "class Workload(Extension):\n\tname = None\n\tdef init_resources(self, context):\n\t\tpass\n"
+ "\tdef validate(self):\n\t\tpass\n\tdef initialize(self, context):\n\t\tpass\n" + "\tdef validate(self):\n\t\tpass\n\tdef initialize(self, context):\n\t\tpass\n"
@ -99,11 +95,8 @@ public class UiAutomation extends UxPerfUiAutomation {
if (useLocalFiles) { if (useLocalFiles) {
testEditFileFromStorage(documents[0]); testEditFileFromStorage(documents[0]);
} else { } else {
// createNewDoc(DOCTYPE_TEMPLATE, DOC_FILENAME); testEditNewSlidesDoc(DOC_FILENAME);
testEditNewSlidesDoc(DOCTYPE_PPT, DOC_FILENAME);
} }
// toggleWifiState(false);
// tapDisplayNormalised(0.99, 0.99); // dismiss help overlay
if (false) { // TODO currently unused if (false) { // TODO currently unused
writeResultsToFile(results, parameters.getString("results_file")); writeResultsToFile(results, parameters.getString("results_file"));
@ -127,7 +120,6 @@ public class UiAutomation extends UxPerfUiAutomation {
} }
protected void testEditFileFromStorage(String document) throws Exception { protected void testEditFileFromStorage(String document) throws Exception {
// UiObject newButton = getUiObjectByResourceId(PACKAGE_ID + "menu_open_with_picker", CLASS_TEXT_VIEW);
UiObject openButton = getUiObjectByDescription("Open presentation", CLASS_TEXT_VIEW); UiObject openButton = getUiObjectByDescription("Open presentation", CLASS_TEXT_VIEW);
openButton.click(); openButton.click();
openButton = getUiObjectByText("Device storage", CLASS_TEXT_VIEW); openButton = getUiObjectByText("Device storage", CLASS_TEXT_VIEW);
@ -138,86 +130,69 @@ public class UiAutomation extends UxPerfUiAutomation {
openButton = getUiObjectByText("Open", CLASS_BUTTON); openButton = getUiObjectByText("Open", CLASS_BUTTON);
openButton.clickAndWaitForNewWindow(); openButton.clickAndWaitForNewWindow();
getUiDevice().pressBack();
sleep(1); sleep(1);
getUiDevice().pressBack();
deleteDocument(document); deleteDocument(document);
} }
protected void testEditNewSlidesDoc(int docType, String docName) throws Exception { protected void testEditNewSlidesDoc(String docName) throws Exception {
UiObject newButton = getUiObjectByDescription("New presentation", CLASS_IMAGE_BUTTON); // create new file
newButton.click(); clickView(BY_DESC, "New presentation");
UiObject view; clickView(BY_TEXT, "New PowerPoint", true);
switch (docType) { // first slide
case DOCTYPE_TEMPLATE: enterTextInSlide("Title", "WORKLOAD AUTOMATION");
String[] templateNames = { "Lesson plan", "Book report", " Field trip", "Science project" }; enterTextInSlide("Subtitle", "Measuring perfomance of different productivity apps on Android OS");
UiObject fromTemplate = getUiObjectByText("Choose template", CLASS_TEXT_VIEW); saveDocument(docName);
fromTemplate.clickAndWaitForNewWindow();
// UiObject template = getUiObjectByText(templateNames[1], CLASS_TEXT_VIEW);
UiObject template = new UiObject(new UiSelector().resourceId(PACKAGE_ID + "template_item").instance(2));
template.clickAndWaitForNewWindow();
break;
case DOCTYPE_SLIDES: insertSlide("Title and Content");
case DOCTYPE_PPT: enterTextInSlide("title", "Introduction");
default: enterTextInSlide("Text placeholder", "Welcome to Documentation for Workload Automation");
UiObject newPowerpoint = getUiObjectByText("New PowerPoint", CLASS_TEXT_VIEW); clickView(BY_DESC, "Undo");
newPowerpoint.clickAndWaitForNewWindow(); enterTextInSlide("Text placeholder", "Workload Automation (WA) is a framework for running workloads on real hardware devices. "
// first slide + "WA supports a number of output formats as well as additional instrumentation "
enterTextInSlide("Title", "WORKLOAD AUTOMATION"); + "(such as Streamline traces). A number of workloads are included with the framework.");
enterTextInSlide("Subtitle", "Measuring perfomance of different productivity apps on Android OS");
saveDocument(docName);
insertSlide("Title and Content"); insertSlide("Title and Content");
enterTextInSlide("title", "Introduction"); enterTextInSlide("title", "Extensions - Workloads");
enterTextInSlide("Text placeholder", "Welcome to Documentation for Workload Automation"); enterTextInSlide("Text placeholder", DOCUMENTATION_WORKLOADS);
view = getViewByDesc("Undo"); clickView(BY_DESC, "Text placeholder");
view.click(); clickView(BY_DESC, "Format");
enterTextInSlide("Text placeholder", "Workload Automation (WA) is a framework for running workloads on real hardware devices. " clickView(BY_TEXT, "Droid Sans");
+ "WA supports a number of output formats as well as additional instrumentation " clickView(BY_TEXT, "Droid Sans Mono");
+ "(such as Streamline traces). A number of workloads are included with the framework."); clickView(BY_ID, PACKAGE_ID + "palette_back_button");
UiObject decreaseFont = getViewByDesc("Decrease text");
repeatClickView(decreaseFont, 20);
getUiDevice().pressBack();
insertSlide("Title and Content"); insertSlide("Title and Content");
enterTextInSlide("title", "Extensions - Workloads"); enterTextInSlide("title", "Agendas - 1");
enterTextInSlide("Text placeholder", DOCUMENTATION_WORKLOADS); enterTextInSlide("Text placeholder", DOCUMENTATION_AGENDAS_1);
clickView(BY_DESC, "Text placeholder");
clickView(BY_DESC, "Format");
clickView(BY_TEXT, "Droid Sans");
clickView(BY_TEXT, "Droid Sans Mono");
clickView(BY_ID, PACKAGE_ID + "palette_back_button");
view = getViewByDesc("Decrease text");
repeatClickView(view, 20);
getUiDevice().pressBack();
insertSlide("Title and Content"); insertSlide("Title and Content");
enterTextInSlide("title", "Agendas - 1"); enterTextInSlide("title", "Agendas - 2");
enterTextInSlide("Text placeholder", DOCUMENTATION_AGENDAS_1); enterTextInSlide("Text placeholder", DOCUMENTATION_AGENDAS_2);
insertSlide("Title and Content"); // get first image in gallery and insert
enterTextInSlide("title", "Agendas - 2"); insertSlide("Title Only");
enterTextInSlide("Text placeholder", DOCUMENTATION_AGENDAS_2); clickView(BY_DESC, "Insert");
clickView(BY_TEXT, "Image", true);
clickView(BY_TEXT, "Recent");
clickView(BY_ID, "com.android.documentsui:id/date", true);
// get first image in gallery and insert // last slide
insertSlide("Title Only"); insertSlide("Title Slide");
clickView(BY_DESC, "Insert"); // insert "?" shape
clickView(BY_TEXT, "Image", true); clickView(BY_DESC, "Insert");
clickView(BY_TEXT, "Recent"); clickView(BY_TEXT, "Shape");
clickView(BY_ID, "com.android.documentsui:id/date", true); clickView(BY_TEXT, "Buttons");
clickView(BY_DESC, "actionButtonHelp");
UiObject resize = getViewByDesc("Bottom-left resize");
UiObject shape = getViewByDesc("actionButtonHelp");
UiObject subtitle = getViewByDesc("subTitle");
resize.dragTo(subtitle, 40);
shape.dragTo(subtitle, 40);
enterTextInSlide("title", "THE END. QUESTIONS?");
// last slide
insertSlide("Title Slide");
// insert "?" shape
clickView(BY_DESC, "Insert");
clickView(BY_TEXT, "Shape");
clickView(BY_TEXT, "Buttons");
clickView(BY_DESC, "actionButtonHelp");
UiObject resize = getViewByDesc("Bottom-left resize");
UiObject shape = getViewByDesc("actionButtonHelp");
UiObject subtitle = getViewByDesc("subTitle");
resize.dragTo(subtitle, 40);
shape.dragTo(subtitle, 40);
enterTextInSlide("title", "THE END. QUESTIONS?");
break;
}
sleep(1); sleep(1);
getUiDevice().pressBack(); getUiDevice().pressBack();
deleteDocument(docName); deleteDocument(docName);