转robotium的API描述

上一篇 / 下一篇  2013-01-14 17:15:23 / 个人分类:android junit

以下为robotium的API描述,接下来的时间内将逐一介绍其作用,以及使用方法,敬请期待~~~~

一、robotium的使用:

Robotium::Solo 3.0API
1、包名:com.jayway.android.robotium.solo
2、构造器:
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

3、方法:
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 for a given amount of time.  

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 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 into a given EditText. 

 void enterText(int index, String text) 
          Enters text into an EditText with a given index. 

 void finalize() 
          Finalizes the solo object and removes the ActivityMonitor. 

 void finishOpenedActivities() 
          All activities that have been active 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.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. 

 android.view.View getView(int id) 
          Returns a View with a given 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. 
 void scrollToSide(int side) 
          Scrolls horizontally. 
 boolean scrollUp() 
          Scrolls up the screen. 
 boolean scrollUpList(int index) 

TAG:

 

评分:0

我来说两句

Open Toolbar