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

Use consistent method names

This commit is contained in:
muendelezaji 2016-05-27 14:37:54 +01:00
parent 403d8ea1bf
commit 51c784f5dd
4 changed files with 57 additions and 57 deletions

View File

@ -42,7 +42,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
public static final int CLICK_REPEAT_INTERVAL_DEFAULT = 50; public static final int CLICK_REPEAT_INTERVAL_DEFAULT = 50;
/* /*
* Used by clickView() methods in order to provide a consistent API * Used by clickUiObject() methods in order to provide a consistent API
*/ */
public enum FindByCriteria { BY_ID, BY_TEXT, BY_DESC; } public enum FindByCriteria { BY_ID, BY_TEXT, BY_DESC; }
@ -294,7 +294,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
getUiDevice().swipe(startX, yCoordinate, endX, yCoordinate, steps); getUiDevice().swipe(startX, yCoordinate, endX, yCoordinate, steps);
} }
public void repeatClickView(UiObject view, int repeatCount, int intervalInMillis) throws Exception { public void repeatClickUiObject(UiObject view, int repeatCount, int intervalInMillis) throws Exception {
int repeatInterval = intervalInMillis > CLICK_REPEAT_INTERVAL_MINIMUM ? intervalInMillis : CLICK_REPEAT_INTERVAL_DEFAULT; int repeatInterval = intervalInMillis > CLICK_REPEAT_INTERVAL_MINIMUM ? intervalInMillis : CLICK_REPEAT_INTERVAL_DEFAULT;
if (repeatCount < 1 || !view.isClickable()) { if (repeatCount < 1 || !view.isClickable()) {
return; return;
@ -305,30 +305,30 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
} }
} }
public UiObject clickView(FindByCriteria criteria, String matching) throws Exception { public UiObject clickUiObject(FindByCriteria criteria, String matching) throws Exception {
return clickView(criteria, matching, null, false); return clickUiObject(criteria, matching, null, false);
} }
public UiObject clickView(FindByCriteria criteria, String matching, boolean wait) throws Exception { public UiObject clickUiObject(FindByCriteria criteria, String matching, boolean wait) throws Exception {
return clickView(criteria, matching, null, wait); return clickUiObject(criteria, matching, null, wait);
} }
public UiObject clickView(FindByCriteria criteria, String matching, String clazz) throws Exception { public UiObject clickUiObject(FindByCriteria criteria, String matching, String clazz) throws Exception {
return clickView(criteria, matching, clazz, false); return clickUiObject(criteria, matching, clazz, false);
} }
public UiObject clickView(FindByCriteria criteria, String matching, String clazz, boolean wait) throws Exception { public UiObject clickUiObject(FindByCriteria criteria, String matching, String clazz, boolean wait) throws Exception {
UiObject view; UiObject view;
switch (criteria) { switch (criteria) {
case BY_ID: case BY_ID:
view = clazz == null ? getViewById(matching) : getUiObjectByResourceId(matching, clazz); view = clazz == null ? getUiObjectByResourceId(matching) : getUiObjectByResourceId(matching, clazz);
break; break;
case BY_DESC: case BY_DESC:
view = clazz == null ? getViewByDesc(matching) : getUiObjectByDescription(matching, clazz); view = clazz == null ? getUiObjectByDescription(matching) : getUiObjectByDescription(matching, clazz);
break; break;
case BY_TEXT: case BY_TEXT:
default: default:
view = clazz == null ? getViewByText(matching) : getUiObjectByText(matching, clazz); view = clazz == null ? getUiObjectByText(matching) : getUiObjectByText(matching, clazz);
break; break;
} }
if (wait) { if (wait) {
@ -339,7 +339,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
return view; return view;
} }
public UiObject getViewByText(String text) throws Exception { public UiObject getUiObjectByText(String text) throws Exception {
UiObject object = new UiObject(new UiSelector().textContains(text)); UiObject object = new UiObject(new UiSelector().textContains(text));
if (!object.waitForExists(waitTimeout)) { if (!object.waitForExists(waitTimeout)) {
throw new UiObjectNotFoundException("Could not find view with text: " + text); throw new UiObjectNotFoundException("Could not find view with text: " + text);
@ -347,7 +347,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
return object; return object;
} }
public UiObject getViewByDesc(String desc) throws Exception { public UiObject getUiObjectByDescription(String desc) throws Exception {
UiObject object = new UiObject(new UiSelector().descriptionContains(desc)); UiObject object = new UiObject(new UiSelector().descriptionContains(desc));
if (!object.waitForExists(waitTimeout)) { if (!object.waitForExists(waitTimeout)) {
throw new UiObjectNotFoundException("Could not find view with description: " + desc); throw new UiObjectNotFoundException("Could not find view with description: " + desc);
@ -355,7 +355,7 @@ public class BaseUiAutomation extends UiAutomatorTestCase {
return object; return object;
} }
public UiObject getViewById(String id) throws Exception { public UiObject getUiObjectByResourceId(String id) throws Exception {
UiObject object = new UiObject(new UiSelector().resourceId(id)); UiObject object = new UiObject(new UiSelector().resourceId(id));
if (!object.waitForExists(waitTimeout)) { if (!object.waitForExists(waitTimeout)) {
throw new UiObjectNotFoundException("Could not find view with resource ID: " + id); throw new UiObjectNotFoundException("Could not find view with resource ID: " + id);

View File

@ -100,7 +100,7 @@ public class UiAutomation extends UxPerfUiAutomation {
protected void skipWelcomeScreen() throws Exception { protected void skipWelcomeScreen() throws Exception {
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_TEXT, "Skip", true); clickUiObject(BY_TEXT, "Skip", true);
timer.end(); timer.end();
results.put("skip_welcome", timer); results.put("skip_welcome", timer);
sleep(1); sleep(1);
@ -110,7 +110,7 @@ public class UiAutomation extends UxPerfUiAutomation {
startDumpsys(ACTIVITY_DOCLIST); startDumpsys(ACTIVITY_DOCLIST);
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_DESC, "drawer"); clickUiObject(BY_DESC, "drawer");
getUiDevice().pressBack(); getUiDevice().pressBack();
timer.end(); timer.end();
results.put("open_drawer", timer); results.put("open_drawer", timer);
@ -122,9 +122,9 @@ public class UiAutomation extends UxPerfUiAutomation {
startDumpsys(ACTIVITY_SETTINGS); startDumpsys(ACTIVITY_SETTINGS);
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_DESC, "drawer"); clickUiObject(BY_DESC, "drawer");
clickView(BY_TEXT, "Settings", true); clickUiObject(BY_TEXT, "Settings", true);
clickView(BY_TEXT, "Create PowerPoint"); clickUiObject(BY_TEXT, "Create PowerPoint");
getUiDevice().pressBack(); getUiDevice().pressBack();
timer.end(); timer.end();
results.put("enable_ppt_compat", timer); results.put("enable_ppt_compat", timer);
@ -148,8 +148,8 @@ public class UiAutomation extends UxPerfUiAutomation {
// Open document // Open document
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_DESC, "Open presentation"); clickUiObject(BY_DESC, "Open presentation");
clickView(BY_TEXT, "Device storage", true); clickUiObject(BY_TEXT, "Device storage", true);
timer.end(); timer.end();
results.put("open_file_picker", timer); results.put("open_file_picker", timer);
@ -158,8 +158,8 @@ public class UiAutomation extends UxPerfUiAutomation {
list.scrollIntoView(new UiSelector().textContains(docName)); list.scrollIntoView(new UiSelector().textContains(docName));
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_TEXT, docName); clickUiObject(BY_TEXT, docName);
clickView(BY_TEXT, "Open", CLASS_BUTTON, true); clickUiObject(BY_TEXT, "Open", CLASS_BUTTON, true);
timer.end(); timer.end();
results.put("open_document", timer); results.put("open_document", timer);
sleep(5); sleep(5);
@ -220,7 +220,7 @@ public class UiAutomation extends UxPerfUiAutomation {
// scroll forward in slideshow mode // scroll forward in slideshow mode
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_DESC, "Start slideshow", true); clickUiObject(BY_DESC, "Start slideshow", true);
timer.end(); timer.end();
results.put("open_slideshow", timer); results.put("open_slideshow", timer);
@ -253,8 +253,8 @@ public class UiAutomation extends UxPerfUiAutomation {
// create new file // create new file
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_DESC, "New presentation"); clickUiObject(BY_DESC, "New presentation");
clickView(BY_TEXT, "New PowerPoint", true); clickUiObject(BY_TEXT, "New PowerPoint", true);
timer.end(); timer.end();
results.put("create_document", timer); results.put("create_document", timer);
endDumpsys(ACTIVITY_DOCLIST, "create_document"); endDumpsys(ACTIVITY_DOCLIST, "create_document");
@ -267,13 +267,13 @@ public class UiAutomation extends UxPerfUiAutomation {
insertSlide("Title and Content"); insertSlide("Title and Content");
enterTextInSlide("title", "Extensions - Workloads"); enterTextInSlide("title", "Extensions - Workloads");
enterTextInSlide("Text placeholder", SLIDE_TEXT_CONTENT); enterTextInSlide("Text placeholder", SLIDE_TEXT_CONTENT);
clickView(BY_DESC, "Text placeholder"); clickUiObject(BY_DESC, "Text placeholder");
clickView(BY_DESC, "Format"); clickUiObject(BY_DESC, "Format");
clickView(BY_TEXT, "Droid Sans"); clickUiObject(BY_TEXT, "Droid Sans");
clickView(BY_TEXT, "Droid Sans Mono"); clickUiObject(BY_TEXT, "Droid Sans Mono");
clickView(BY_ID, PACKAGE_ID + "palette_back_button"); clickUiObject(BY_ID, PACKAGE_ID + "palette_back_button");
UiObject decreaseFont = getViewByDesc("Decrease text"); UiObject decreaseFont = getUiObjectByDescription("Decrease text");
repeatClickView(decreaseFont, 20, CLICK_REPEAT_INTERVAL_MS); repeatClickUiObject(decreaseFont, 20, CLICK_REPEAT_INTERVAL_MS);
getUiDevice().pressBack(); getUiDevice().pressBack();
// get image from gallery and insert // get image from gallery and insert
@ -281,26 +281,26 @@ public class UiAutomation extends UxPerfUiAutomation {
// folder it's in. More reliable than trying to find a pushed image in the file // folder it's in. More reliable than trying to find a pushed image in the file
// picker, and fails gracefully in the rare case that no images exist. // picker, and fails gracefully in the rare case that no images exist.
insertSlide("Title Only"); insertSlide("Title Only");
clickView(BY_DESC, "Insert"); clickUiObject(BY_DESC, "Insert");
clickView(BY_TEXT, "Image", true); clickUiObject(BY_TEXT, "Image", true);
clickView(BY_TEXT, "Recent"); clickUiObject(BY_TEXT, "Recent");
try { try {
UiObject image = new UiObject(new UiSelector().resourceId("com.android.documentsui:id/date").instance(2)); UiObject image = new UiObject(new UiSelector().resourceId("com.android.documentsui:id/date").instance(2));
image.clickAndWaitForNewWindow(); image.clickAndWaitForNewWindow();
} catch (UiObjectNotFoundException e) { } catch (UiObjectNotFoundException e) {
clickView(BY_ID, "com.android.documentsui:id/date", true); clickUiObject(BY_ID, "com.android.documentsui:id/date", true);
} }
// last slide // last slide
insertSlide("Title Slide"); insertSlide("Title Slide");
// insert "?" shape // insert "?" shape
clickView(BY_DESC, "Insert"); clickUiObject(BY_DESC, "Insert");
clickView(BY_TEXT, "Shape"); clickUiObject(BY_TEXT, "Shape");
clickView(BY_TEXT, "Buttons"); clickUiObject(BY_TEXT, "Buttons");
clickView(BY_DESC, "actionButtonHelp"); clickUiObject(BY_DESC, "actionButtonHelp");
UiObject resize = getViewByDesc("Bottom-left resize"); UiObject resize = getUiObjectByDescription("Bottom-left resize");
UiObject shape = getViewByDesc("actionButtonHelp"); UiObject shape = getUiObjectByDescription("actionButtonHelp");
UiObject subtitle = getViewByDesc("subTitle"); UiObject subtitle = getUiObjectByDescription("subTitle");
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?");
@ -312,20 +312,20 @@ public class UiAutomation extends UxPerfUiAutomation {
public void insertSlide(String slideLayout) throws Exception { public void insertSlide(String slideLayout) throws Exception {
sleep(1); // a bit of time to see previous slide sleep(1); // a bit of time to see previous slide
UiObject view = getViewByDesc("Insert slide"); UiObject view = getUiObjectByDescription("Insert slide");
view.clickAndWaitForNewWindow(); view.clickAndWaitForNewWindow();
view = getViewByText(slideLayout); view = getUiObjectByText(slideLayout);
view.clickAndWaitForNewWindow(); view.clickAndWaitForNewWindow();
} }
public void enterTextInSlide(String viewName, String textToEnter) throws Exception { public void enterTextInSlide(String viewName, String textToEnter) throws Exception {
UiObject view = getViewByDesc(viewName); UiObject view = getUiObjectByDescription(viewName);
view.click(); view.click();
view.setText(textToEnter); view.setText(textToEnter);
try { try {
clickView(BY_DESC, "Done"); clickUiObject(BY_DESC, "Done");
} catch (UiObjectNotFoundException e) { } catch (UiObjectNotFoundException e) {
clickView(BY_ID, "android:id/action_mode_close_button"); clickUiObject(BY_ID, "android:id/action_mode_close_button");
} }
// On some devices, keyboard pops up when entering text, and takes a noticeable // On some devices, keyboard pops up when entering text, and takes a noticeable
// amount of time (few milliseconds) to disappear after clicking Done. // amount of time (few milliseconds) to disappear after clicking Done.
@ -337,17 +337,17 @@ public class UiAutomation extends UxPerfUiAutomation {
public void saveDocument(String docName) throws Exception { public void saveDocument(String docName) throws Exception {
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
clickView(BY_TEXT, "SAVE"); clickUiObject(BY_TEXT, "SAVE");
clickView(BY_TEXT, "Device"); clickUiObject(BY_TEXT, "Device");
timer.end(); timer.end();
results.put("save_dialog_1", timer); results.put("save_dialog_1", timer);
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
UiObject filename = getViewById(PACKAGE_ID + "file_name_edit_text"); UiObject filename = getUiObjectByResourceId(PACKAGE_ID + "file_name_edit_text");
filename.clearTextField(); filename.clearTextField();
filename.setText(docName); filename.setText(docName);
clickView(BY_TEXT, "Save", CLASS_BUTTON); clickUiObject(BY_TEXT, "Save", CLASS_BUTTON);
timer.end(); timer.end();
results.put("save_dialog_2", timer); results.put("save_dialog_2", timer);
@ -358,7 +358,7 @@ public class UiAutomation extends UxPerfUiAutomation {
// part of the UiAutomator test case. // part of the UiAutomator test case.
UiObject overwriteView = new UiObject(new UiSelector().textContains("already exists")); UiObject overwriteView = new UiObject(new UiSelector().textContains("already exists"));
if (overwriteView.waitForExists(DIALOG_WAIT_TIME_MS)) { if (overwriteView.waitForExists(DIALOG_WAIT_TIME_MS)) {
clickView(BY_TEXT, "Overwrite"); clickUiObject(BY_TEXT, "Overwrite");
} }
sleep(1); sleep(1);
} }
@ -366,9 +366,9 @@ public class UiAutomation extends UxPerfUiAutomation {
public void deleteDocument(String docName) throws Exception { public void deleteDocument(String docName) throws Exception {
timer = new Timer(); timer = new Timer();
timer.start(); timer.start();
UiObject doc = getViewByText(docName); UiObject doc = getUiObjectByText(docName);
doc.longClick(); doc.longClick();
clickView(BY_TEXT, "Remove"); clickUiObject(BY_TEXT, "Remove");
timer.end(); timer.end();
results.put("delete_dialog_1", timer); results.put("delete_dialog_1", timer);