老李分享:robotium3.6与4.0 later 的区别

老李分享:robotium3.6与4.0 later 的区别

因为下载的直接是最新版本的robotium4.1版,这次碰到gridView问题时,发现网上有getCurrentListViews() 、getCurrentImageViews()等方法。而自己却没有,纳闷了,下载查看了下3.6版本,果然有。

3.6版本中的方法:

 

 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.
<T extends android.widget.LinearLayout> 
ArrayList<T>
getCurrentNumberPickers() 
          Returns an ArrayList of the NumberPicker 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.

 

 

再仔细看了下4.0中的方法:

 

 java.util.ArrayList<android.view.View> getCurrentViews() 
          Returns an ArrayList of the Views currently displayed in the focused Activity or Dialog.
<T extends android.view.View> 
java.util.ArrayList<T>
getCurrentViews(java.lang.Class<T> classToFilterBy) 
          Returns an ArrayList of Views matching the specified class located in the focused Activity or Dialog.
<T extends android.view.View> 
java.util.ArrayList<T>
getCurrentViews(java.lang.Class<T> classToFilterBy, android.view.View parent) 
          Returns an ArrayList of Views matching the specified class located under the specified parent.

虽然只剩下了三个getCurrentViews()方法,但却可以替代3.6的众多方法

java.lang.Class<T> classToFilterBy参数传入相应的类即可

例如:ArrayList<ImageView> imageList=solo.getCurrentViews(ImageView.class);得到的即是ImageView

            ArrayList<ImageView> imageList=solo.getCurrentViews(ImageView.class,parentView);


你可能感兴趣的:(测试)