|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jayway.android.robotium.solo.Solo
public class Solo
This class contains all the methods that the sub-classes have. It supports test cases that span over multiple activities. It supports regular expressions and will automatically scroll when needed. When writing tests there is no need to plan for or expect new activities in the test case. All is handled automatically by Robotium-Solo. Robotium-Solo can be used in conjunction with ActivityInstrumentationTestCase2. The test cases are written from a user perspective were technical details are not needed. Example of usage (test case spanning over multiple activities):
public void setUp() throws Exception { solo = new Solo(getInstrumentation(), getActivity()); } public void testTextShows() throws Exception { solo.clickOnText("Categories"); solo.clickOnText("Other"); solo.clickOnButton("Edit"); solo.searchText("Edit Window"); solo.clickOnButton("Commit"); assertTrue(solo.searchText("Changes have been made successfully")); }
Field Summary | |
---|---|
static int |
LEFT
|
static int |
RIGHT
|
Constructor Summary | |
---|---|
Solo(android.app.Instrumentation inst,
android.app.Activity activity)
Constructor that takes in the instrumentation and the start activity. |
Method Summary | |
---|---|
void |
assertCurrentActivity(String message,
Class expectedClass)
Method used to assert that an expected activity is currently active. |
void |
assertCurrentActivity(String message,
Class expectedClass,
boolean isNewInstance)
Method used to assert that an expected activity is currently active with the possibility to verify that the expected activity is a new instance of the activity. |
void |
assertCurrentActivity(String message,
String name)
Method used to assert that an expected activity is currently active. |
void |
assertCurrentActivity(String message,
String name,
boolean isNewInstance)
Method used to assert that an expected activity is currently active with the possibility to verify that the expected activity is a new instance of the activity. |
void |
clickLongOnScreen(android.view.View view)
Method used to long click on a specific view. |
void |
clickLongOnTextAndPress(String text,
int index)
This method is used to long click on a specific text view and then selecting an item from the menu that appears. |
boolean |
clickOnButton(int index)
This method used to click on a button with a specific index. |
void |
clickOnButton(String name)
Method used to click on a button with a given text. |
void |
clickOnImage(int index)
This method is used to click on an image with a certain index. |
void |
clickOnScreen(android.view.View view)
Method used to click on a specific view. |
void |
clickOnText(String text)
This method is used to click on a specific view displaying a certain text. |
void |
drag(float fromX,
float toX,
float fromY,
float toY,
int stepCount)
Simulate touching a specific location and dragging to a new location. |
void |
enterText(int index,
String text)
This method is used to enter text into an EditText or a NoteField with a certain index. |
void |
finalize()
All activites that have been active are finished. |
ArrayList<android.app.Activity> |
getAllOpenedActivities()
This method returns an ArrayList of all the opened/active activities. |
android.widget.Button |
getButton(int index)
This method returns a button with a certain index. |
int |
getCurrenButtonsCount()
This method returns the number of buttons located in the current activity. |
android.app.Activity |
getCurrentActivity()
This method returns the current activity. |
ArrayList<android.widget.Button> |
getCurrentButtons()
This method returns an ArrayList with the buttons located in the current activity. |
ArrayList<android.widget.EditText> |
getCurrentEditTexts()
This method returns an ArrayList of all the edit texts located in the current activity. |
ArrayList<android.widget.GridView> |
getCurrentGridViews()
This method returns an ArrayList of the grid views located in the current activity. |
ArrayList<android.widget.ImageView> |
getCurrentImageViews()
This method returns an ArrayList of the images contained in the current activity. |
ArrayList<android.widget.ListView> |
getCurrentListViews()
This method returns an ArrayList of all the list views located in the current activity. |
ArrayList<android.widget.Spinner> |
getCurrentSpinners()
This method returns an ArrayList of spinners (drop-down menus) located in the current activity. |
ArrayList<android.widget.TextView> |
getCurrentTextViews(android.view.View parent)
This method returns an ArrayList of the text views located in the current activity. |
android.widget.EditText |
getEditText(int index)
This method returns an EditText with a certain index. |
android.view.View |
getTopParent(android.view.View view)
Method used to get the absolute top view in an activity. |
ArrayList<android.view.View> |
getViews()
This method returns an ArrayList of all the views located in the current activity. |
void |
goBack()
Method used to simulate pressing the hard key back. |
void |
pressMenuItem(int index)
Method used to press a MenuItem with a certain index. |
void |
pressSpinnerItem(int spinnerIndex,
int itemIndex)
Method used to press on a spinner (drop-down menu) item. |
boolean |
scrollDownList()
This method is used to scroll down a list or scroll view. |
void |
scrollToSide(int side)
This method is used to scroll horizontally. |
void |
scrollUpList()
This method is used to scroll up a list. |
boolean |
searchButton(String search)
Searches for a button with the given search string and returns true if at least one button is found with the expected text. |
boolean |
searchButton(String search,
int matches)
Searches for a button with the given search string and returns true if the searched button is found a given number of times. |
boolean |
searchEditText(String search)
Searches for a text string in the edit texts located in the current activity. |
boolean |
searchText(String search)
Searches for a text string and returns true if at least one item is found with the expected text. |
boolean |
searchText(String search,
int matches)
Searches for a text string and returns true if the searched text is found a given number of times. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int RIGHT
public static final int LEFT
Constructor Detail |
---|
public Solo(android.app.Instrumentation inst, android.app.Activity activity)
inst
- the instrumentation objectactivity
- the start activityMethod Detail |
---|
public ArrayList<android.view.View> getViews()
public android.view.View getTopParent(android.view.View view)
view
- the view whose top parent is requested
public boolean searchEditText(String search)
search
- the search string to be searched
public boolean searchButton(String search)
search
- the string to be searched. Regular expressions are supported
public boolean searchButton(String search, int matches)
search
- the string to be searched. Regular expressions are supportedmatches
- the number of matches expected to be found. 0 matches means that one or more
matches are expected to be found
public boolean searchText(String search)
search
- the string to be searched. Regular expressions are supported
public boolean searchText(String search, int matches)
search
- the string to be searched. Regular expressions are supportedmatches
- the number of matches expected to be found. 0 matches means that one or more
matches are expected to be found
public ArrayList<android.app.Activity> getAllOpenedActivities()
public android.app.Activity getCurrentActivity()
public void assertCurrentActivity(String message, String name)
message
- the message that should be displayed if the assert failsname
- the name of the activity that is expected to be active e.g. "MyActivity"public void assertCurrentActivity(String message, Class expectedClass)
message
- the message that should be displayed if the assert failsexpectedClass
- the class object that is expected to be active e.g. MyActivity.classpublic void assertCurrentActivity(String message, String name, boolean isNewInstance)
message
- the message that should be displayed if the assert failsname
- the name of the activity that is expected to be active e.g. "MyActivity"isNewInstance
- true if the expected activity is a new instance of the activitypublic void assertCurrentActivity(String message, Class expectedClass, boolean isNewInstance)
message
- the message that should be displayed if the assert failsexpectedClass
- the class object that is expected to be active e.g. MyActivity.classisNewInstance
- true if the expected activity is a new instance of the activitypublic void goBack()
public void clickOnButton(String name)
name
- the name of the button presented to the user. Regular expressions are supportedpublic void pressMenuItem(int index)
index
- the index of the menu item to be pressedpublic void pressSpinnerItem(int spinnerIndex, int itemIndex)
spinnerIndex
- the index of the spinner menu to be useditemIndex
- the index of the spinner item to be pressedpublic void clickOnScreen(android.view.View view)
view
- the view that should be clickedpublic void clickLongOnScreen(android.view.View view)
view
- the view that should be long clickedpublic void clickOnText(String text)
text
- the text that should be clicked on. Regular expressions are supportedpublic void clickLongOnTextAndPress(String text, int index)
text
- the text that should be clicked on. Regular expressions are supportedindex
- the index of the menu item that should be pressedpublic boolean clickOnButton(int index)
index
- the index number of the button
public void drag(float fromX, float toX, float fromY, float toY, int stepCount)
TouchUtils.java
in the Android Open Source Project, and modified here.
fromX
- X coordinate of the initial touch, in screen coordinatestoX
- Xcoordinate of the drag destination, in screen coordinatesfromY
- X coordinate of the initial touch, in screen coordinatestoY
- Y coordinate of the drag destination, in screen coordinatesstepCount
- How many move steps to include in the dragpublic boolean scrollDownList()
public void scrollUpList()
public void scrollToSide(int side)
side
- the side in which to scrollpublic void enterText(int index, String text)
index
- the index of the text field. Index 0 if only one available.text
- the text string that is to be entered into the text fieldpublic void clickOnImage(int index)
index
- the index of the image to be clickedpublic ArrayList<android.widget.ImageView> getCurrentImageViews()
public android.widget.EditText getEditText(int index)
public android.widget.Button getButton(int index)
index
- the index of the button
public int getCurrenButtonsCount()
public ArrayList<android.widget.EditText> getCurrentEditTexts()
public ArrayList<android.widget.ListView> getCurrentListViews()
public ArrayList<android.widget.Spinner> getCurrentSpinners()
public ArrayList<android.widget.TextView> getCurrentTextViews(android.view.View parent)
parent
- the parent View in which the text views should be returned. Null if
all text views from the current activity should be returned
public ArrayList<android.widget.GridView> getCurrentGridViews()
public ArrayList<android.widget.Button> getCurrentButtons()
public void finalize() throws Throwable
finalize
in class Object
Throwable
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |