|
|||||||||
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
Contains all the methods that the sub-classes have. It supports test cases that span over multiple activities. Robotium has full support for Activities, Dialogs, Toasts, Menus and Context Menus. 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 | |
---|---|
protected com.jayway.android.robotium.solo.ActivityUtils |
activityUtils
|
protected com.jayway.android.robotium.solo.Asserter |
asserter
|
protected com.jayway.android.robotium.solo.Checker |
checker
|
protected com.jayway.android.robotium.solo.Clicker |
clicker
|
static int |
CLOSED
|
static int |
DELETE
|
protected com.jayway.android.robotium.solo.DialogUtils |
dialogUtils
|
static int |
DOWN
|
static int |
ENTER
|
protected com.jayway.android.robotium.solo.Getter |
getter
|
static int |
LANDSCAPE
|
static int |
LEFT
|
static int |
MENU
|
static int |
OPENED
|
static int |
PORTRAIT
|
protected com.jayway.android.robotium.solo.Presser |
presser
|
static int |
RIGHT
|
protected com.jayway.android.robotium.solo.RobotiumUtils |
robotiumUtils
|
protected com.jayway.android.robotium.solo.Scroller |
scroller
|
protected com.jayway.android.robotium.solo.Searcher |
searcher
|
protected com.jayway.android.robotium.solo.Setter |
setter
|
protected com.jayway.android.robotium.solo.Sleeper |
sleeper
|
protected int |
SMALLTIMEOUT
|
protected com.jayway.android.robotium.solo.TextEnterer |
textEnterer
|
protected int |
TIMEOUT
|
static int |
UP
|
protected com.jayway.android.robotium.solo.Waiter |
waiter
|
protected com.jayway.android.robotium.solo.ViewFetcher |
viewFetcher
|
Constructor Summary | |
---|---|
Solo(android.app.Instrumentation instrumentation)
Constructor that takes in the instrumentation. |
|
Solo(android.app.Instrumentation instrumentation,
android.app.Activity activity)
Constructor that takes in the instrumentation and the start activity. |
Method Summary | ||
---|---|---|
void |
assertCurrentActivity(String message,
Class expectedClass)
Asserts that the expected Activity is the currently active one. |
|
void |
assertCurrentActivity(String message,
Class expectedClass,
boolean isNewInstance)
Asserts that the expected Activity is the currently active one, with the possibility to verify that the expected Activity is a new instance of the Activity. |
|
void |
assertCurrentActivity(String message,
String name)
Asserts that the expected Activity is the currently active one. |
|
void |
assertCurrentActivity(String message,
String name,
boolean isNewInstance)
Asserts that the expected Activity is the currently active one, with the possibility to verify that the expected Activity is a new instance of the Activity. |
|
void |
assertMemoryNotLow()
Asserts that the available memory in the system is not low. |
|
void |
clearEditText(android.widget.EditText editText)
Clears the value of an EditText. |
|
void |
clearEditText(int index)
Clears the value of an EditText. |
|
ArrayList<android.widget.TextView> |
clickInList(int line)
Clicks on a given list line and returns an ArrayList of the TextView objects that the list line is showing. |
|
ArrayList<android.widget.TextView> |
clickInList(int line,
int index)
Clicks on a given list line on a specified list and returns an ArrayList of the TextView objects that the list line is showing. |
|
ArrayList<android.widget.TextView> |
clickLongInList(int line)
Long clicks on a given list line and returns an ArrayList of the TextView objects that the list line is showing. |
|
ArrayList<android.widget.TextView> |
clickLongInList(int line,
int index)
Long clicks on a given list line on a specified list and returns an ArrayList of the TextView objects that the list line is showing. |
|
ArrayList<android.widget.TextView> |
clickLongInList(int line,
int index,
int time)
Long clicks on a given list line on a specified list and returns an ArrayList of the TextView objects that the list line is showing. |
|
void |
clickLongOnScreen(float x,
float y)
Long clicks a given coordinate on the screen. |
|
void |
clickLongOnScreen(float x,
float y,
int time)
Long clicks a given coordinate on the screen for a given amount of time. |
|
void |
clickLongOnText(String text)
Long clicks on a given View. |
|
void |
clickLongOnText(String text,
int match)
Long clicks on a given View. |
|
void |
clickLongOnText(String text,
int match,
boolean scroll)
Long clicks on a given View. |
|
void |
clickLongOnText(String text,
int match,
int time)
Long clicks on a given View. |
|
void |
clickLongOnTextAndPress(String text,
int index)
Long clicks on a given View and then selects an item from the context menu that appears. |
|
void |
clickLongOnView(android.view.View view)
Long clicks on a given View. |
|
void |
clickLongOnView(android.view.View view,
int time)
Long clicks on a given View for a given amount of time. |
|
void |
clickOnActionBarHomeButton()
Clicks on an ActionBar Home/Up button. |
|
void |
clickOnActionBarItem(int resourceId)
Clicks on an ActionBar item with a given resource id. |
|
void |
clickOnButton(int index)
Clicks on a Button with a given index. |
|
void |
clickOnButton(String name)
Clicks on a Button with a given text. |
|
void |
clickOnCheckBox(int index)
Clicks on a CheckBox with a given index. |
|
void |
clickOnEditText(int index)
Clicks on an EditText with a given index. |
|
void |
clickOnImage(int index)
Clicks on an ImageView with a given index. |
|
void |
clickOnImageButton(int index)
Clicks on an ImageButton with a given index. |
|
void |
clickOnMenuItem(String text)
Clicks on a MenuItem with a given text. |
|
void |
clickOnMenuItem(String text,
boolean subMenu)
Clicks on a MenuItem with a given text. |
|
void |
clickOnRadioButton(int index)
Clicks on a RadioButton with a given index. |
|
void |
clickOnScreen(float x,
float y)
Clicks on a given coordinate on the screen. |
|
void |
clickOnText(String text)
Clicks on a View displaying a given text. |
|
void |
clickOnText(String text,
int match)
Clicks on a View displaying a given text. |
|
void |
clickOnText(String text,
int match,
boolean scroll)
Clicks on a View displaying a given text. |
|
void |
clickOnToggleButton(String name)
Clicks on a ToggleButton with a given text. |
|
void |
clickOnView(android.view.View view)
Clicks on a given View. |
|
void |
drag(float fromX,
float toX,
float fromY,
float toY,
int stepCount)
Simulate touching a given location and dragging it to a new location. |
|
void |
enterText(android.widget.EditText editText,
String text)
Enters text in a given EditText. |
|
void |
enterText(int index,
String text)
Enters text in an EditText with a given index. |
|
void |
finalize()
Finalizes the solo object and removes the ActivityMonitor. |
|
void |
finishInactiveActivities()
Deprecated. Method has been deprecated as there are no longer strong references to activities. |
|
void |
finishOpenedActivities()
The activities that are alive are finished. |
|
android.app.Instrumentation.ActivityMonitor |
getActivityMonitor()
Returns the ActivityMonitor used by Robotium. |
|
ArrayList<android.app.Activity> |
getAllOpenedActivities()
Returns an ArrayList of all the opened/active activities. |
|
android.widget.Button |
getButton(int index)
Returns a Button with a given index. |
|
android.widget.Button |
getButton(String text)
Returns a Button which shows a given text. |
|
android.widget.Button |
getButton(String text,
boolean onlyVisible)
Returns a Button which shows a given text. |
|
android.app.Activity |
getCurrentActivity()
Returns the current Activity. |
|
ArrayList<android.widget.Button> |
getCurrentButtons()
Returns an ArrayList of the Button objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.CheckBox> |
getCurrentCheckBoxes()
Returns an ArrayList of the CheckBox objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.DatePicker> |
getCurrentDatePickers()
Returns an ArrayList of the DatePicker objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.EditText> |
getCurrentEditTexts()
Returns an ArrayList of the EditText objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.GridView> |
getCurrentGridViews()
Returns an ArrayList of the GridView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ImageButton> |
getCurrentImageButtons()
Returns an ArrayList of the ImageButton objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ImageView> |
getCurrentImageViews()
Returns an ArrayList of the ImageView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ImageView> |
getCurrentImageViews(android.view.View parent)
Returns an ArrayList of the ImageView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ListView> |
getCurrentListViews()
Returns an ArrayList of the ListView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ProgressBar> |
getCurrentProgressBars()
Returns an ArrayList of the ProgressBar objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.RadioButton> |
getCurrentRadioButtons()
Returns an ArrayList of the RadioButton objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ScrollView> |
getCurrentScrollViews()
Returns an ArrayList of the ScrollView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.SlidingDrawer> |
getCurrentSlidingDrawers()
Returns an ArrayList of the SlidingDrawer objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.Spinner> |
getCurrentSpinners()
Returns an ArrayList of the Spinner objects (drop-down menus) currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.TextView> |
getCurrentTextViews(android.view.View parent)
Returns an ArrayList of the TextView objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.TimePicker> |
getCurrentTimePickers()
Returns an ArrayList of the TimePicker objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.widget.ToggleButton> |
getCurrentToggleButtons()
Returns an ArrayList of the ToggleButton objects currently shown in the focused Activity or Dialog. |
|
ArrayList<android.view.View> |
getCurrentViews()
Returns an ArrayList of the View objects currently shown in the focused Activity or Dialog. |
|
android.widget.EditText |
getEditText(int index)
Returns an EditText with a given index. |
|
android.widget.EditText |
getEditText(String text)
Returns an EditText which shows a given text. |
|
android.widget.EditText |
getEditText(String text,
boolean onlyVisible)
Returns an EditText which shows a given text. |
|
android.widget.ImageView |
getImage(int index)
Returns an ImageView with a given index. |
|
android.widget.ImageButton |
getImageButton(int index)
Returns an ImageButton with a given index. |
|
String |
getString(int resId)
Returns a localized string. |
|
android.widget.TextView |
getText(int index)
Returns a TextView with a given index. |
|
android.widget.TextView |
getText(String text)
Returns a TextView which shows a given text. |
|
android.widget.TextView |
getText(String text,
boolean onlyVisible)
Returns a TextView which shows a given text. |
|
android.view.View |
getTopParent(android.view.View view)
Returns the absolute top parent View for a given View. |
|
|
getView(Class<T> viewClass,
int index)
Returns a View of a given class and index. |
|
android.view.View |
getView(int id)
Returns a View with a given resource id. |
|
ArrayList<android.view.View> |
getViews()
Returns an ArrayList of all the View objects located in the focused Activity or Dialog. |
|
ArrayList<android.view.View> |
getViews(android.view.View parent)
Returns an ArrayList of the View objects contained in the parent View. |
|
void |
goBack()
Simulates pressing the hardware back key. |
|
void |
goBackToActivity(String name)
Returns to the given Activity. |
|
boolean |
isCheckBoxChecked(int index)
Checks if a CheckBox with a given index is checked. |
|
boolean |
isCheckBoxChecked(String text)
Checks if a CheckBox with a given text is checked. |
|
boolean |
isRadioButtonChecked(int index)
Checks if a RadioButton with a given index is checked. |
|
boolean |
isRadioButtonChecked(String text)
Checks if a RadioButton with a given text is checked. |
|
boolean |
isSpinnerTextSelected(int index,
String text)
Checks if a given text is selected in a given Spinner. |
|
boolean |
isSpinnerTextSelected(String text)
Checks if a given text is selected in any Spinner located in the current screen. |
|
boolean |
isTextChecked(String text)
Checks if the given text is checked. |
|
boolean |
isToggleButtonChecked(int index)
Checks if a ToggleButton with a given index is checked. |
|
boolean |
isToggleButtonChecked(String text)
Checks if a ToggleButton with a given text is checked. |
|
void |
pressMenuItem(int index)
Presses a MenuItem with a given index. |
|
void |
pressMenuItem(int index,
int itemsPerRow)
Presses a MenuItem with a given index. |
|
void |
pressSpinnerItem(int spinnerIndex,
int itemIndex)
Presses on a Spinner (drop-down menu) item. |
|
boolean |
scrollDown()
Scrolls down the screen. |
|
boolean |
scrollDownList(int index)
Scrolls down a list with a given index. |
|
boolean |
scrollListToBottom(int index)
Scrolls a list with a given index to the bottom. |
|
boolean |
scrollListToTop(int index)
Scrolls a list with a given index to the top. |
|
void |
scrollToBottom()
Scrolls to the bottom of the screen. |
|
void |
scrollToSide(int side)
Scrolls horizontally. |
|
void |
scrollToTop()
Scrolls to the top of the screen. |
|
boolean |
scrollUp()
Scrolls up the screen. |
|
boolean |
scrollUpList(int index)
Scrolls up a list with a given index. |
|
boolean |
searchButton(String text)
Searches for a Button with the given text string and returns true if at least one Button is found. |
|
boolean |
searchButton(String text,
boolean onlyVisible)
Searches for a Button with the given text string and returns true if at least one Button is found. |
|
boolean |
searchButton(String text,
int minimumNumberOfMatches)
Searches for a Button with the given text string and returns true if the
searched Button is found a given number of times. |
|
boolean |
searchButton(String text,
int minimumNumberOfMatches,
boolean onlyVisible)
Searches for a Button with the given text string and returns true if the
searched Button is found a given number of times. |
|
boolean |
searchEditText(String text)
Searches for a text string in the EditText objects currently shown and returns true if found. |
|
boolean |
searchText(String text)
Searches for a text string and returns true if at least one item
is found with the expected text. |
|
boolean |
searchText(String text,
boolean onlyVisible)
Searches for a text string and returns true if at least one item
is found with the expected text. |
|
boolean |
searchText(String text,
int minimumNumberOfMatches)
Searches for a text string and returns true if the searched text is found a given
number of times. |
|
boolean |
searchText(String text,
int minimumNumberOfMatches,
boolean scroll)
Searches for a text string and returns true if the searched text is found a given
number of times. |
|
boolean |
searchText(String text,
int minimumNumberOfMatches,
boolean scroll,
boolean onlyVisible)
Searches for a text string and returns true if the searched text is found a given
number of times. |
|
boolean |
searchToggleButton(String text)
Searches for a ToggleButton with the given text string and returns true if at least one ToggleButton
is found. |
|
boolean |
searchToggleButton(String text,
int minimumNumberOfMatches)
Searches for a ToggleButton with the given text string and returns true if the
searched ToggleButton is found a given number of times. |
|
void |
sendKey(int key)
Sends a key: Right, Left, Up, Down, Enter, Menu or Delete. |
|
void |
setActivityOrientation(int orientation)
Sets the Orientation (Landscape/Portrait) for the current activity. |
|
void |
setDatePicker(android.widget.DatePicker datePicker,
int year,
int monthOfYear,
int dayOfMonth)
Sets the date in a given DatePicker. |
|
void |
setDatePicker(int index,
int year,
int monthOfYear,
int dayOfMonth)
Sets the date in a DatePicker with a given index. |
|
void |
setProgressBar(int index,
int progress)
Sets the progress of a ProgressBar with a given index. |
|
void |
setProgressBar(android.widget.ProgressBar progressBar,
int progress)
Sets the progress of a given ProgressBar. |
|
void |
setSlidingDrawer(int index,
int status)
Sets the status of a SlidingDrawer with a given index. |
|
void |
setSlidingDrawer(android.widget.SlidingDrawer slidingDrawer,
int status)
Sets the status of a given SlidingDrawer. |
|
void |
setTimePicker(int index,
int hour,
int minute)
Sets the time in a TimePicker with a given index. |
|
void |
setTimePicker(android.widget.TimePicker timePicker,
int hour,
int minute)
Sets the time in a given TimePicker. |
|
void |
sleep(int time)
Robotium will sleep for a specified time. |
|
void |
takeScreenshot()
Takes a screenshot and saves it in "/sdcard/Robotium-Screenshots/". |
|
void |
takeScreenshot(String name)
Takes a screenshot and saves it with a given name in "/sdcard/Robotium-Screenshots/". |
|
void |
typeText(android.widget.EditText editText,
String text)
Types text in a given EditText. |
|
void |
typeText(int index,
String text)
Types text in an EditText with a given index. |
|
boolean |
waitForActivity(String name)
Waits for the given Activity. |
|
boolean |
waitForActivity(String name,
int timeout)
Waits for the given Activity. |
|
boolean |
waitForDialogToClose(long timeout)
Waits for a Dialog to close. |
|
boolean |
waitForFragmentById(int id)
Waits for a Fragment with a given id to appear. |
|
boolean |
waitForFragmentById(int id,
int timeout)
Waits for a Fragment with a given id to appear. |
|
boolean |
waitForFragmentByTag(String tag)
Waits for a Fragment with a given tag to appear. |
|
boolean |
waitForFragmentByTag(String tag,
int timeout)
Waits for a Fragment with a given tag to appear. |
|
boolean |
waitForLogMessage(String logMessage)
Waits for a log message to appear. |
|
boolean |
waitForLogMessage(String logMessage,
int timeout)
Waits for a log message to appear. |
|
boolean |
waitForText(String text)
Waits for a text to be shown. |
|
boolean |
waitForText(String text,
int minimumNumberOfMatches,
long timeout)
Waits for a text to be shown. |
|
boolean |
waitForText(String text,
int minimumNumberOfMatches,
long timeout,
boolean scroll)
Waits for a text to be shown. |
|
boolean |
waitForText(String text,
int minimumNumberOfMatches,
long timeout,
boolean scroll,
boolean onlyVisible)
Waits for a text to be shown. |
|
|
waitForView(Class<T> viewClass)
Waits for a View of a certain class to be shown. |
|
|
waitForView(Class<T> viewClass,
int minimumNumberOfMatches,
int timeout)
Waits for a View of a certain class to be shown. |
|
|
waitForView(Class<T> viewClass,
int minimumNumberOfMatches,
int timeout,
boolean scroll)
Waits for a View of a certain class to be shown. |
|
|
waitForView(android.view.View view)
Waits for a given View to be shown. |
|
|
waitForView(android.view.View view,
int timeout,
boolean scroll)
Waits for a given View to be shown. |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final com.jayway.android.robotium.solo.Asserter asserter
protected final com.jayway.android.robotium.solo.ViewFetcher viewFetcher
protected final com.jayway.android.robotium.solo.Checker checker
protected final com.jayway.android.robotium.solo.Clicker clicker
protected final com.jayway.android.robotium.solo.Presser presser
protected final com.jayway.android.robotium.solo.Searcher searcher
protected final com.jayway.android.robotium.solo.ActivityUtils activityUtils
protected final com.jayway.android.robotium.solo.DialogUtils dialogUtils
protected final com.jayway.android.robotium.solo.TextEnterer textEnterer
protected final com.jayway.android.robotium.solo.Scroller scroller
protected final com.jayway.android.robotium.solo.RobotiumUtils robotiumUtils
protected final com.jayway.android.robotium.solo.Sleeper sleeper
protected final com.jayway.android.robotium.solo.Waiter waiter
protected final com.jayway.android.robotium.solo.Setter setter
protected final com.jayway.android.robotium.solo.Getter getter
protected final int TIMEOUT
protected final int SMALLTIMEOUT
public static final int LANDSCAPE
public static final int PORTRAIT
public static final int RIGHT
public static final int LEFT
public static final int UP
public static final int DOWN
public static final int ENTER
public static final int MENU
public static final int DELETE
public static final int CLOSED
public static final int OPENED
Constructor Detail |
---|
public Solo(android.app.Instrumentation instrumentation, android.app.Activity activity)
instrumentation
- the Instrumentation
instanceactivity
- the start Activity
or null
if no start activity is providedpublic Solo(android.app.Instrumentation instrumentation)
instrumentation
- the Instrumentation
instanceMethod Detail |
---|
public android.app.Instrumentation.ActivityMonitor getActivityMonitor()
public ArrayList<android.view.View> getViews()
ArrayList
of the View
objects located in the focused windowpublic ArrayList<android.view.View> getViews(android.view.View parent)
parent
- the parent view from which to return the views
ArrayList
of the View
objects contained in the given View
public android.view.View getTopParent(android.view.View view)
view
- the View
whose top parent is requested
View
public boolean waitForText(String text)
text
- the text to wait for
true
if text is shown and false
if it is not shown before the timeoutpublic boolean waitForText(String text, int minimumNumberOfMatches, long timeout)
text
- the text to wait forminimumNumberOfMatches
- the minimum number of matches that are expected to be shown. 0
means any number of matchestimeout
- the the amount of time in milliseconds to wait
true
if text is shown and false
if it is not shown before the timeoutpublic boolean waitForText(String text, int minimumNumberOfMatches, long timeout, boolean scroll)
text
- the text to wait forminimumNumberOfMatches
- the minimum number of matches that are expected to be shown. 0
means any number of matchestimeout
- the the amount of time in milliseconds to waitscroll
- true
if scrolling should be performed
true
if text is shown and false
if it is not shown before the timeoutpublic boolean waitForText(String text, int minimumNumberOfMatches, long timeout, boolean scroll, boolean onlyVisible)
text
- the text to wait forminimumNumberOfMatches
- the minimum number of matches that are expected to be shown. 0
means any number of matchestimeout
- the the amount of time in milliseconds to waitscroll
- true
if scrolling should be performedonlyVisible
- true
if only visible text views should be waited for
true
if text is shown and false
if it is not shown before the timeoutpublic <T extends android.view.View> boolean waitForView(Class<T> viewClass)
viewClass
- the View
class to wait forpublic <T extends android.view.View> boolean waitForView(android.view.View view)
view
- the View
object to wait for
true
if view is shown and false
if it is not shown before the timeoutpublic <T extends android.view.View> boolean waitForView(android.view.View view, int timeout, boolean scroll)
view
- the View
object to wait fortimeout
- the amount of time in milliseconds to waitscroll
- true
if scrolling should be performed
true
if view is shown and false
if it is not shown before the timeoutpublic <T extends android.view.View> boolean waitForView(Class<T> viewClass, int minimumNumberOfMatches, int timeout)
viewClass
- the View
class to wait forminimumNumberOfMatches
- the minimum number of matches that are expected to be shown. 0
means any number of matchestimeout
- the amount of time in milliseconds to wait
true
if view is shown and false
if it is not shown before the timeoutpublic <T extends android.view.View> boolean waitForView(Class<T> viewClass, int minimumNumberOfMatches, int timeout, boolean scroll)
viewClass
- the View
class to wait forminimumNumberOfMatches
- the minimum number of matches that are expected to be shown. 0
means any number of matchestimeout
- the amount of time in milliseconds to waitscroll
- true
if scrolling should be performed
true
if the View
is shown and false
if it is not shown before the timeoutpublic boolean searchEditText(String text)
text
- the text to search for
true
if an EditText
with the given text is found or false
if it is not foundpublic boolean searchButton(String text)
text
- the text to search for. The parameter will be interpreted as a regular expression
true
if a Button
with the given text is found and false
if it is not foundpublic boolean searchButton(String text, boolean onlyVisible)
text
- the text to search for. The parameter will be interpreted as a regular expressiononlyVisible
- true
if only Button
visible on the screen should be searched
true
if a Button
with the given text is found and false
if it is not foundpublic boolean searchToggleButton(String text)
true
if at least one ToggleButton
is found. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expression
true
if a ToggleButton
with the given text is found and false
if it is not foundpublic boolean searchButton(String text, int minimumNumberOfMatches)
true
if the
searched Button is found a given number of times. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expressionminimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be found
true
if a Button
with the given text is found a given number of times and false
if it is not foundpublic boolean searchButton(String text, int minimumNumberOfMatches, boolean onlyVisible)
true
if the
searched Button is found a given number of times. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expressionminimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be foundonlyVisible
- true
if only Button
visible on the screen should be searched
true
if a Button
with the given text is found a given number of times and false
if it is not foundpublic boolean searchToggleButton(String text, int minimumNumberOfMatches)
true
if the
searched ToggleButton is found a given number of times. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expressionminimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be found
true
if a ToggleButton
with the given text is found a given number of times and false
if it is not foundpublic boolean searchText(String text)
true
if at least one item
is found with the expected text. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expression
true
if the search string is found and false
if it is not foundpublic boolean searchText(String text, boolean onlyVisible)
true
if at least one item
is found with the expected text. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expressiononlyVisible
- true
if only texts visible on the screen should be searched
true
if the search string is found and false
if it is not foundpublic boolean searchText(String text, int minimumNumberOfMatches)
true
if the searched text is found a given
number of times. Will automatically scroll when needed.
text
- the text to search for. The parameter will be interpreted as a regular expressionminimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be found
true
if text string is found a given number of times and false
if the text string
is not foundpublic boolean searchText(String text, int minimumNumberOfMatches, boolean scroll)
true
if the searched text is found a given
number of times.
text
- the text to search for. The parameter will be interpreted as a regular expression.minimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be foundscroll
- true
if scrolling should be performed
true
if text string is found a given number of times and false
if the text string
is not foundpublic boolean searchText(String text, int minimumNumberOfMatches, boolean scroll, boolean onlyVisible)
true
if the searched text is found a given
number of times.
text
- the text to search for. The parameter will be interpreted as a regular expression.minimumNumberOfMatches
- the minimum number of matches expected to be found. 0
matches means that one or more
matches are expected to be foundscroll
- true
if scrolling should be performedonlyVisible
- true
if only texts visible on the screen should be searched
true
if text string is found a given number of times and false
if the text string
is not foundpublic void setActivityOrientation(int orientation)
orientation
- the orientation to be set. Solo.
LANDSCAPE
for landscape or
Solo.
PORTRAIT
for portrait.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.class
public 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 Activity
public 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.class
isNewInstance
- true
if the expected Activity
is a new instance of the Activity
public void assertMemoryNotLow()
public boolean waitForDialogToClose(long timeout)
timeout
- the amount of time in milliseconds to wait
true
if the Dialog
is closed before the timeout and false
if it is not closedpublic void goBack()
public void clickOnScreen(float x, float y)
x
- the x coordinatey
- the y coordinatepublic void clickLongOnScreen(float x, float y)
x
- the x coordinatey
- the y coordinatepublic void clickLongOnScreen(float x, float y, int time)
x
- the x coordinatey
- the y coordinatetime
- the amount of time to long clickpublic void clickOnButton(String name)
name
- the name of the Button
presented to the user. The parameter will be interpreted as a regular expressionpublic void clickOnImageButton(int index)
index
- the index of the ImageButton
to be clicked. 0 if only one is availablepublic void clickOnToggleButton(String name)
name
- the name of the ToggleButton
presented to the user. The parameter will be interpreted as a regular expressionpublic void clickOnMenuItem(String text)
text
- the menu text that should be clicked on. The parameter will be interpreted as a regular expressionpublic void clickOnMenuItem(String text, boolean subMenu)
text
- the menu text that should be clicked on. The parameter will be interpreted as a regular expressionsubMenu
- true if the menu item could be located in a sub menupublic void pressMenuItem(int index)
0
is the first item in the
first row, Index 3
is the first item in the second row and
index 6
is the first item in the third row.
index
- the index of the MenuItem
to be pressedpublic void pressMenuItem(int index, int itemsPerRow)
index
- the index of the MenuItem
to be presseditemsPerRow
- the amount of menu items there are per row.public void pressSpinnerItem(int spinnerIndex, int itemIndex)
spinnerIndex
- the index of the Spinner
menu to be useditemIndex
- the index of the Spinner
item to be pressed relative to the currently selected item
A Negative number moves up on the Spinner
, positive moves downpublic void clickOnView(android.view.View view)
view
- the View
that should be clickedpublic void clickLongOnView(android.view.View view)
view
- the View
that should be long clickedpublic void clickLongOnView(android.view.View view, int time)
view
- the View
that should be long clickedtime
- the amount of time to long clickpublic void clickOnText(String text)
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionpublic void clickOnText(String text, int match)
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionmatch
- if multiple objects match the text, this determines which one will be clickedpublic void clickOnText(String text, int match, boolean scroll)
text
- the text that should be clicked on. The parameter will be interpreted as a regular expressionmatch
- if multiple objects match the text, this determines which one will be clickedscroll
- true if scrolling should be performedpublic void clickLongOnText(String text)
clickOnText(String)
can then be
used to click on the context menu items that appear after the long click.
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionpublic void clickLongOnText(String text, int match)
clickOnText(String)
can then be
used to click on the context menu items that appear after the long click.
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionmatch
- if multiple objects match the text, this determines which one will be clickedpublic void clickLongOnText(String text, int match, boolean scroll)
clickOnText(String)
can then be
used to click on the context menu items that appear after the long click.
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionmatch
- if multiple objects match the text, this determines which one will be clickedscroll
- true if scrolling should be performedpublic void clickLongOnText(String text, int match, int time)
clickOnText(String)
can then be
used to click on the context menu items that appear after the long click.
text
- the text that should be clicked. The parameter will be interpreted as a regular expressionmatch
- if multiple objects match the text, this determines which one will be clickedtime
- the amount of time to long clickpublic void clickLongOnTextAndPress(String text, int index)
text
- the text to be clicked. The parameter will be interpreted as a regular expressionindex
- the index of the menu item to be pressed. 0
if only one is availablepublic void clickOnButton(int index)
index
- the index of the Button
to be clicked. 0
if only one is availablepublic void clickOnRadioButton(int index)
index
- the index of the RadioButton
to be clicked. 0
if only one is availablepublic void clickOnCheckBox(int index)
index
- the index of the CheckBox
to be clicked. 0
if only one is availablepublic void clickOnEditText(int index)
index
- the index of the EditText
to be clicked. 0
if only one is availablepublic ArrayList<android.widget.TextView> clickInList(int line)
line
- the line that should be clicked
ArrayList
of the TextView
objects located in the list linepublic ArrayList<android.widget.TextView> clickInList(int line, int index)
line
- the line that should be clickedindex
- the index of the list. 1 if two lists are available
ArrayList
of the TextView
objects located in the list linepublic ArrayList<android.widget.TextView> clickLongInList(int line)
line
- the line that should be clicked
ArrayList
of the TextView
objects located in the list linepublic ArrayList<android.widget.TextView> clickLongInList(int line, int index)
line
- the line that should be clickedindex
- the index of the list. 1 if two lists are available
ArrayList
of the TextView
objects located in the list linepublic ArrayList<android.widget.TextView> clickLongInList(int line, int index, int time)
line
- the line that should be clickedindex
- the index of the list. 1 if two lists are availabletime
- the amount of time to long click
ArrayList
of the TextView
objects located in the list linepublic void clickOnActionBarItem(int resourceId)
resourceId
- the R.id of the ActionBar itempublic void clickOnActionBarHomeButton()
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
- X coordinate 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 scrollDown()
true
if more scrolling can be done and false
if it is at the end of
the screenpublic void scrollToBottom()
public boolean scrollUp()
true
if more scrolling can be done and false
if it is at the top of
the screenpublic void scrollToTop()
public boolean scrollDownList(int index)
index
- the ListView
to be scrolled. 0
if only one list is available
true
if more scrolling can be donepublic boolean scrollListToBottom(int index)
index
- the ListView
to be scrolled. 0
if only one list is available
true
if more scrolling can be donepublic boolean scrollUpList(int index)
index
- the ListView
to be scrolled. 0
if only one list is available
true
if more scrolling can be donepublic boolean scrollListToTop(int index)
index
- the ListView
to be scrolled. 0
if only one list is available
true
if more scrolling can be donepublic void scrollToSide(int side)
side
- the side to which to scroll; RIGHT
or LEFT
public void setDatePicker(int index, int year, int monthOfYear, int dayOfMonth)
index
- the index of the DatePicker
. 0
if only one is availableyear
- the year e.g. 2011monthOfYear
- the month which starts from zero e.g. 0 for JanuarydayOfMonth
- the day e.g. 10public void setDatePicker(android.widget.DatePicker datePicker, int year, int monthOfYear, int dayOfMonth)
datePicker
- the DatePicker
object.year
- the year e.g. 2011monthOfYear
- the month which starts from zero e.g. 03 for AprildayOfMonth
- the day e.g. 10public void setTimePicker(int index, int hour, int minute)
index
- the index of the TimePicker
. 0
if only one is availablehour
- the hour e.g. 15minute
- the minute e.g. 30public void setTimePicker(android.widget.TimePicker timePicker, int hour, int minute)
timePicker
- the TimePicker
object.hour
- the hour e.g. 15minute
- the minute e.g. 30public void setProgressBar(int index, int progress)
index
- the index of the ProgressBar
progress
- the progress that the ProgressBar
should be set topublic void setProgressBar(android.widget.ProgressBar progressBar, int progress)
progressBar
- the ProgressBar
progress
- the progress that the ProgressBar
should be set topublic void setSlidingDrawer(int index, int status)
index
- the index of the SlidingDrawer
status
- the status that the SlidingDrawer
should be set topublic void setSlidingDrawer(android.widget.SlidingDrawer slidingDrawer, int status)
slidingDrawer
- the SlidingDrawer
status
- the status that the SlidingDrawer
should be set topublic void enterText(int index, String text)
index
- the index of the EditText
. 0
if only one is availabletext
- the text string to enter into the EditText
fieldpublic void enterText(android.widget.EditText editText, String text)
editText
- the EditText
to enter text intotext
- the text string to enter into the EditText
fieldpublic void typeText(int index, String text)
index
- the index of the EditText
. 0
if only one is availabletext
- the text string to type in the EditText
fieldpublic void typeText(android.widget.EditText editText, String text)
editText
- the EditText
to type text intext
- the text string to type in the EditText
fieldpublic void clearEditText(int index)
index
- the index of the EditText
that should be cleared. 0 if only one is availablepublic void clearEditText(android.widget.EditText editText)
editText
- the EditText
that should be clearedpublic void clickOnImage(int index)
index
- the index of the ImageView
to be clicked. 0
if only one is availablepublic android.widget.EditText getEditText(int index)
index
- the index of the EditText
. 0
if only one is available
EditText
with a specified index or null
if index is invalidpublic android.widget.Button getButton(int index)
index
- the index of the Button
. 0
if only one is available
Button
with a specified index or null
if index is invalidpublic android.widget.TextView getText(int index)
index
- the index of the TextView
. 0
if only one is available
TextView
with a specified index or null
if index is invalidpublic android.widget.ImageView getImage(int index)
index
- the index of the ImageView
. 0
if only one is available
ImageView
with a specified index or null
if index is invalidpublic android.widget.ImageButton getImageButton(int index)
index
- the index of the ImageButton
. 0
if only one is available
ImageButton
with a specified index or null
if index is invalidpublic android.widget.TextView getText(String text)
text
- the text that is shown
TextView
that shows the given textpublic android.widget.TextView getText(String text, boolean onlyVisible)
text
- the text that is shownonlyVisible
- true
if only visible texts on the screen should be returned
TextView
that shows the given textpublic android.widget.Button getButton(String text)
text
- the text that is shown
Button
that shows the given textpublic android.widget.Button getButton(String text, boolean onlyVisible)
text
- the text that is shownonlyVisible
- true
if only visible buttons on the screen should be returned
Button
that shows the given textpublic android.widget.EditText getEditText(String text)
text
- the text that is shown
EditText
which shows the given textpublic android.widget.EditText getEditText(String text, boolean onlyVisible)
text
- the text that is shownonlyVisible
- true
if only visible EditTexts on the screen should be returned
EditText
which shows the given textpublic android.view.View getView(int id)
id
- the R.id of the View
to be returned
View
with a given idpublic <T extends android.view.View> android.view.View getView(Class<T> viewClass, int index)
viewClass
- the class of the requested viewindex
- the index of the View
. 0
if only one is available
View
with a given class and indexpublic ArrayList<android.view.View> getCurrentViews()
ArrayList
of the View
objects currently shown in the
focused windowpublic ArrayList<android.widget.ImageView> getCurrentImageViews()
ArrayList
of the ImageView
objects currently shown in the
focused windowpublic ArrayList<android.widget.ImageView> getCurrentImageViews(android.view.View parent)
parent
- the parent View
from which the ImageView
objects should be returned. null
if
all TextView objects from the currently focused window e.g. Activity should be returned
ArrayList
of the ImageView
objects currently shown in the
focused windowpublic ArrayList<android.widget.EditText> getCurrentEditTexts()
ArrayList
of the EditText
objects currently shown in the
focused windowpublic ArrayList<android.widget.ListView> getCurrentListViews()
ArrayList
of the ListView
objects currently shown in the
focused windowpublic ArrayList<android.widget.ScrollView> getCurrentScrollViews()
ArrayList
of the ScrollView
objects currently shown in the
focused windowpublic ArrayList<android.widget.Spinner> getCurrentSpinners()
ArrayList
of the Spinner
objects (drop-down menus) currently shown in the
focused windowpublic ArrayList<android.widget.TextView> getCurrentTextViews(android.view.View parent)
parent
- the parent View
from which the TextView
objects should be returned. null
if
all TextView objects from the currently focused window e.g. Activity should be returned
ArrayList
of the TextView
objects currently shown in the
focused windowpublic ArrayList<android.widget.GridView> getCurrentGridViews()
ArrayList
of the GridView
objects currently shown in the
focused windowpublic ArrayList<android.widget.Button> getCurrentButtons()
ArrayList
of the Button
objects currently shown in the
focused windowpublic ArrayList<android.widget.ToggleButton> getCurrentToggleButtons()
ArrayList
of the ToggleButton
objects currently shown in the
focused windowpublic ArrayList<android.widget.RadioButton> getCurrentRadioButtons()
ArrayList
of the RadioButton
objects currently shown in the
focused windowpublic ArrayList<android.widget.CheckBox> getCurrentCheckBoxes()
ArrayList
of the CheckBox
objects currently shown in the
focused windowpublic ArrayList<android.widget.ImageButton> getCurrentImageButtons()
ArrayList
of the ImageButton
objects currently shown in the
focused windowpublic ArrayList<android.widget.DatePicker> getCurrentDatePickers()
ArrayList
of the DatePicker
objects currently shown in the
focused windowpublic ArrayList<android.widget.TimePicker> getCurrentTimePickers()
ArrayList
of the TimePicker
objects currently shown in the
focused windowpublic ArrayList<android.widget.SlidingDrawer> getCurrentSlidingDrawers()
ArrayList
of the SlidingDrawer
objects currently shown in the
focused windowpublic ArrayList<android.widget.ProgressBar> getCurrentProgressBars()
ArrayList
of the ProgressBar
objects currently shown in the
focused windowpublic boolean isRadioButtonChecked(int index)
index
- of the RadioButton
to check. 0
if only one is available
true
if RadioButton
is checked and false
if it is not checkedpublic boolean isRadioButtonChecked(String text)
text
- the text that the RadioButton
shows
true
if a RadioButton
with the given text is checked and false
if it is not checkedpublic boolean isCheckBoxChecked(int index)
index
- of the CheckBox
to check. 0
if only one is available
true
if CheckBox
is checked and false
if it is not checkedpublic boolean isToggleButtonChecked(String text)
text
- the text that the ToggleButton
shows
true
if a ToggleButton
with the given text is checked and false
if it is not checkedpublic boolean isToggleButtonChecked(int index)
index
- of the ToggleButton
to check. 0
if only one is available
true
if ToggleButton
is checked and false
if it is not checkedpublic boolean isCheckBoxChecked(String text)
text
- the text that the CheckBox
shows
true
if a CheckBox
with the given text is checked and false
if it is not checkedpublic boolean isTextChecked(String text)
text
- the text that the CheckedTextView
or CompoundButton
objects show
true
if the given text is checked and false
if it is not checkedpublic boolean isSpinnerTextSelected(String text)
text
- the text that is expected to be selected
true
if the given text is selected in any Spinner
and false if it is notpublic boolean isSpinnerTextSelected(int index, String text)
index
- the index of the spinner to check. 0
if only one spinner is availabletext
- the text that is expected to be selected
Spinner
and false if it is notpublic void sendKey(int key)
key
- the key to be sent. Use Solo.
RIGHT
, LEFT
, UP
, DOWN
,
ENTER
, MENU
, DELETE
public void goBackToActivity(String name)
name
- the name of the Activity
to return to, e.g. "MyActivity"
public boolean waitForActivity(String name)
name
- the name of the Activity
to wait for e.g. "MyActivity"
true
if Activity
appears before the timeout and false
if it does notpublic boolean waitForActivity(String name, int timeout)
name
- the name of the Activity
to wait for e.g. "MyActivity"
timeout
- the amount of time in milliseconds to wait
true
if Activity
appears before the timeout and false
if it does notpublic boolean waitForFragmentByTag(String tag)
tag
- the name of the tag
public boolean waitForFragmentByTag(String tag, int timeout)
tag
- the name of the tagtimeout
- the amount of time in milliseconds to wait
public boolean waitForFragmentById(int id)
id
- the id of the fragment
public boolean waitForFragmentById(int id, int timeout)
id
- the id of the fragmenttimeout
- the amount of time in milliseconds to wait
public boolean waitForLogMessage(String logMessage)
logMessage
- the log message to wait for
public boolean waitForLogMessage(String logMessage, int timeout)
logMessage
- the log message to wait fortimeout
- the amount of time in milliseconds to wait
public String getString(int resId)
resId
- the resource id of the string
public void sleep(int time)
time
- the time in milliseconds that Robotium should sleeppublic void finalize() throws Throwable
finalize
in class Object
Throwable
finishOpenedActivities() to close the activities that have been active.
public void finishInactiveActivities()
public void finishOpenedActivities()
public void takeScreenshot()
public void takeScreenshot(String name)
name
- the name to give the screenshot
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |