android.test.InstrumentationTestCase Java Examples

The following examples show how to use android.test.InstrumentationTestCase. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: WeexUiTestCaseTCAHrefEvent.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void setUpToFindComponet(String target, InstrumentationTestCase test){
    int max = 60;
    int count = 0;
    while(mCaseListIndexView.size() == 0){

        if (count < max){
            TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
            count ++;
        }
        else{
            break;
        }

    }
}
 
Example #2
Source File: WeexUiTestCaseTCAHrefUpdate.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void setUpToFindComponet(String target, InstrumentationTestCase test){
    int max = 60;
    int count = 0;
    while(mCaseListIndexView.size() == 0){

        if (count < max){
            TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
            count ++;
        }
        else{
            targetComponetNotFound = true;
        }

    }
}
 
Example #3
Source File: WeexUiTestCaseTCAHrefStyle.java    From incubator-weex-playground with Apache License 2.0 6 votes vote down vote up
/**
 *
 */
public void setUpToFindComponet(String target, InstrumentationTestCase test){
    int max = 60;
    int count = 0;
    while(mCaseListIndexView.size() == 0){

        if (count < max){
            TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
            count ++;
        }
        else{
            break;
        }

    }
}
 
Example #4
Source File: AndroidTestResult.java    From android-test with Apache License 2.0 5 votes vote down vote up
@Override
protected void run(final TestCase test) {
  if (test instanceof AndroidTestCase) {
    ((AndroidTestCase) test).setContext(instr.getTargetContext());
  }
  if (test instanceof InstrumentationTestCase) {
    ((InstrumentationTestCase) test).injectInstrumentation(instr);
  }
  super.run(test);
}
 
Example #5
Source File: UiTestUtils.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public static void saveAndRestoreInstanceState(final InstrumentationTestCase test, final Activity activity) throws Throwable {
    test.runTestOnUiThread(new Runnable() {
        @Override
        public void run() {
            Bundle outState = new Bundle();
            test.getInstrumentation().callActivityOnSaveInstanceState(activity, outState);
            test.getInstrumentation().callActivityOnPause(activity);
            test.getInstrumentation().callActivityOnResume(activity);
            test.getInstrumentation().callActivityOnRestoreInstanceState(activity, outState);
        }
    });
    test.getInstrumentation().waitForIdleSync();
}
 
Example #6
Source File: UiTestUtils.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public static void swipeHorizontally(InstrumentationTestCase test, View v, Direction direction) {
    int[] xy = new int[2];
    v.getLocationOnScreen(xy);

    final int viewWidth = v.getWidth();
    final int viewHeight = v.getHeight();

    float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            v.getResources().getDisplayMetrics());
    float xStart = xy[0] + ((direction == Direction.LEFT) ? (viewWidth - distanceFromEdge) : distanceFromEdge);
    float xEnd = xy[0] + ((direction == Direction.LEFT) ? distanceFromEdge : (viewWidth - distanceFromEdge));
    float y = xy[1] + (viewHeight / 2.0f);

    TouchUtils.drag(test, xStart, xEnd, y, y, DRAG_STEP_COUNT);
}
 
Example #7
Source File: UiTestUtils.java    From Android-ObservableScrollView with Apache License 2.0 5 votes vote down vote up
public static void swipeVertically(InstrumentationTestCase test, View v, Direction direction) {
    int[] xy = new int[2];
    v.getLocationOnScreen(xy);

    final int viewWidth = v.getWidth();
    final int viewHeight = v.getHeight();

    float distanceFromEdge = TypedValue.applyDimension(TypedValue.COMPLEX_UNIT_DIP, 8,
            v.getResources().getDisplayMetrics());
    float x = xy[0] + (viewWidth / 2.0f);
    float yStart = xy[1] + ((direction == Direction.UP) ? (viewHeight - distanceFromEdge) : distanceFromEdge);
    float yEnd = xy[1] + ((direction == Direction.UP) ? distanceFromEdge : (viewHeight - distanceFromEdge));

    TouchUtils.drag(test, x, x, yStart, yEnd, DRAG_STEP_COUNT);
}
 
Example #8
Source File: TestUtil.java    From ExoPlayer-Offline with Apache License 2.0 4 votes vote down vote up
public static void setUpMockito(InstrumentationTestCase instrumentationTestCase) {
  // Workaround for https://code.google.com/p/dexmaker/issues/detail?id=2.
  System.setProperty("dexmaker.dexcache",
      instrumentationTestCase.getInstrumentation().getTargetContext().getCacheDir().getPath());
  MockitoAnnotations.initMocks(instrumentationTestCase);
}
 
Example #9
Source File: ViewUtil.java    From incubator-weex-playground with Apache License 2.0 2 votes vote down vote up
public static void dragQuarterScreenUp(InstrumentationTestCase test, Activity activity) {

        TouchUtils.dragQuarterScreenUp(test, activity);
    }
 
Example #10
Source File: AmazonWebViewOnUiThread.java    From cordova-amazon-fireos with Apache License 2.0 2 votes vote down vote up
/**
 * Initializes the webView with a WebViewClient, WebChromeClient, and PictureListener to prepare for
 * loadUrlAndWaitForCompletion. A new WebViewOnUiThread should be called during setUp so as to reinitialize between
 * calls.
 * 
 * @param test
 *            The test in which this is being run.
 * @param webView
 *            The webView that the methods should call.
 * @see loadUrlAndWaitForCompletion
 */
public AmazonWebViewOnUiThread(InstrumentationTestCase test,
    CordovaWebView webView) {
    mTest = test;
    mWebView = webView;
}