下面列出了怎么用android.test.ActivityInstrumentationTestCase2的API类实例代码及写法,或者点击链接到github查看源代码。
/**
* Initialize Robotium
*
* @param ActivityInstrumentationTestCase2
*/
public RobotiumWrapperRobot(ActivityInstrumentationTestCase2<?> test)
{
testCase = test;
solo = new Solo (testCase.getInstrumentation(), testCase.getActivity());
//init widget lists
this.theViews = new HashMap<Integer,View>();
this.allViews = new ArrayList<View>();
}
@Override
public void swapTab (final TabHost t, int num) {
assertNotNull(t, "Cannon swap tab: the tab host does not exist");
int count = t.getTabWidget().getTabCount();
ActivityInstrumentationTestCase2.assertTrue("Cannot swap tab: tab index out of bound", num<=count);
final int n = Math.min(count, Math.max(1,num))-1;
Debug.info(this, "Swapping to tab " + num);
click (t.getTabWidget().getChildAt(n));
}
/**
* assertNotNull proxy
*
* @param v
*/
protected void assertNotNull (final View v)
{
ActivityInstrumentationTestCase2.assertNotNull(v);
}
/**
* assertNotNull proxy
*
* @param v
*/
protected void assertNotNull (final View v, String errorMessage)
{
ActivityInstrumentationTestCase2.assertNotNull(errorMessage, v);
}