1
0
mirror of https://github.com/ARM-software/workload-automation.git synced 2025-03-25 20:18:47 +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,30 +130,15 @@ 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) {
case DOCTYPE_TEMPLATE:
String[] templateNames = { "Lesson plan", "Book report", " Field trip", "Science project" };
UiObject fromTemplate = getUiObjectByText("Choose template", CLASS_TEXT_VIEW);
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:
case DOCTYPE_PPT:
default:
UiObject newPowerpoint = getUiObjectByText("New PowerPoint", CLASS_TEXT_VIEW);
newPowerpoint.clickAndWaitForNewWindow();
// first slide // first slide
enterTextInSlide("Title", "WORKLOAD AUTOMATION"); enterTextInSlide("Title", "WORKLOAD AUTOMATION");
enterTextInSlide("Subtitle", "Measuring perfomance of different productivity apps on Android OS"); enterTextInSlide("Subtitle", "Measuring perfomance of different productivity apps on Android OS");
@ -170,8 +147,7 @@ public class UiAutomation extends UxPerfUiAutomation {
insertSlide("Title and Content"); insertSlide("Title and Content");
enterTextInSlide("title", "Introduction"); enterTextInSlide("title", "Introduction");
enterTextInSlide("Text placeholder", "Welcome to Documentation for Workload Automation"); enterTextInSlide("Text placeholder", "Welcome to Documentation for Workload Automation");
view = getViewByDesc("Undo"); clickView(BY_DESC, "Undo");
view.click();
enterTextInSlide("Text placeholder", "Workload Automation (WA) is a framework for running workloads on real hardware devices. " enterTextInSlide("Text placeholder", "Workload Automation (WA) is a framework for running workloads on real hardware devices. "
+ "WA supports a number of output formats as well as additional instrumentation " + "WA supports a number of output formats as well as additional instrumentation "
+ "(such as Streamline traces). A number of workloads are included with the framework."); + "(such as Streamline traces). A number of workloads are included with the framework.");
@ -184,8 +160,8 @@ public class UiAutomation extends UxPerfUiAutomation {
clickView(BY_TEXT, "Droid Sans"); clickView(BY_TEXT, "Droid Sans");
clickView(BY_TEXT, "Droid Sans Mono"); clickView(BY_TEXT, "Droid Sans Mono");
clickView(BY_ID, PACKAGE_ID + "palette_back_button"); clickView(BY_ID, PACKAGE_ID + "palette_back_button");
view = getViewByDesc("Decrease text"); UiObject decreaseFont = getViewByDesc("Decrease text");
repeatClickView(view, 20); repeatClickView(decreaseFont, 20);
getUiDevice().pressBack(); getUiDevice().pressBack();
insertSlide("Title and Content"); insertSlide("Title and Content");
@ -216,8 +192,7 @@ public class UiAutomation extends UxPerfUiAutomation {
resize.dragTo(subtitle, 40); resize.dragTo(subtitle, 40);
shape.dragTo(subtitle, 40); shape.dragTo(subtitle, 40);
enterTextInSlide("title", "THE END. QUESTIONS?"); enterTextInSlide("title", "THE END. QUESTIONS?");
break;
}
sleep(1); sleep(1);
getUiDevice().pressBack(); getUiDevice().pressBack();
deleteDocument(docName); deleteDocument(docName);