Java 类android.test.InstrumentationTestCase 实例源码

项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefEvent.java   
/**
 *
 */
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;
        }

    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefUpdate.java   
/**
 *
 */
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;
        }

    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefStyle.java   
/**
 *
 */
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;
        }

    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefEvent.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){
    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefUpdate.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){
    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefUpdate.java   
/**
 *
 */
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;
        }

    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefStyle.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){

    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefStyle.java   
/**
 *
 */
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;
        }

    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefEvent.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){
    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefEvent.java   
/**
 *
 */
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;
        }

    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefUpdate.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){
    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefUpdate.java   
/**
 *
 */
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;
        }

    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefStyle.java   
/**
 *
 */
public void findTargetComponetIfNotFound(String target, InstrumentationTestCase test){

    if(mCaseListIndexView.size() ==1 || targetComponetNotFound){
        if(((WXTextView)mCaseListIndexView.get(0))
                .getText()
                .toString()
                .equals("TC__Home")){

            TouchUtils.dragQuarterScreenUp(test,WXPageActivity.wxPageActivityInstance );
            mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
            mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
        }

        TouchUtils.dragQuarterScreenUp(test, WXPageActivity.wxPageActivityInstance );
        mViewGroup = (ViewGroup) WXPageActivity.wxPageActivityInstance.findViewById(R.id.container);
        mCaseListIndexView = ViewUtil.findViewWithText(mViewGroup, target);
    }
}
项目:Weex-TestDemo    文件:WeexUiTestCaseTCAHrefStyle.java   
/**
 *
 */
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;
        }

    }
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:google-authenticator-android    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:google-authenticator-android-pebble    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:google-authenticator.android    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:glassauth    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:otp-authenticator-android    文件:TestUtilities.java   
/**
 * Taps the specified preference displayed by the provided Activity.
 */
public static void tapPreference(InstrumentationTestCase instrumentationTestCase,
    PreferenceActivity activity, Preference preference) {
  // IMPLEMENTATION NOTE: There's no obvious way to find out which View corresponds to the
  // preference because the Preference list in the adapter is flattened, whereas the View
  // hierarchy in the ListView is not.
  // Thus, we go for the Reflection-based invocation of Preference.performClick() which is as
  // close to the invocation stack of a normal tap as it gets.

  // Only perform the click if the preference is in the adapter to catch cases where the
  // preference is not part of the PreferenceActivity for some reason.
  ListView listView = activity.getListView();
  ListAdapter listAdapter = listView.getAdapter();
  for (int i = 0, len = listAdapter.getCount(); i < len; i++) {
    if (listAdapter.getItem(i) == preference) {
      invokePreferencePerformClickOnMainThread(
          instrumentationTestCase.getInstrumentation(),
          preference,
          activity.getPreferenceScreen());
      return;
    }
  }
  throw new IllegalArgumentException("Preference " + preference + " not in list");
}
项目:weex-3d-map    文件:WeexUiTestCaseTCAHrefEvent.java   
/**
 *
 */
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;
        }

    }
}
项目:AndroidObservableScrollView-master    文件:UiTestUtils.java   
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();
}
项目:AndroidObservableScrollView-master    文件:UiTestUtils.java   
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);
}
项目:AndroidObservableScrollView-master    文件:UiTestUtils.java   
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);
}
项目:Android-ObservableScrollView    文件:UiTestUtils.java   
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();
}
项目:Android-ObservableScrollView    文件:UiTestUtils.java   
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);
}
项目:Android-ObservableScrollView    文件:UiTestUtils.java   
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);
}
项目:StudyMovie    文件:UiTestUtils.java   
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();
}
项目:StudyMovie    文件:UiTestUtils.java   
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);
}
项目:StudyMovie    文件:UiTestUtils.java   
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);
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the positive button of a currently displayed dialog. This method assumes that a button
 * of the dialog is currently selected.
 *
 * @see #tapDialogNegativeButton(InstrumentationTestCase)
 */
public static void tapDialogNegativeButton(InstrumentationTestCase testCase) {
  // The order of the buttons is reversed from ICS onwards
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    testCase.sendKeys("DPAD_RIGHT DPAD_CENTER");
  } else {
    testCase.sendKeys("DPAD_LEFT DPAD_CENTER");
  }
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the negative button of a currently displayed dialog. This method assumes that a button
 * of the dialog is currently selected.
 *
 * @see #tapDialogNegativeButton(InstrumentationTestCase)
 */
public static void tapDialogPositiveButton(InstrumentationTestCase testCase) {
  // The order of the buttons is reversed from ICS onwards
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    testCase.sendKeys("DPAD_LEFT DPAD_CENTER");
  } else {
    testCase.sendKeys("DPAD_RIGHT DPAD_CENTER");
  }
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the negative button of a currently displayed 3 button dialog. This method assumes
 * that a button of the dialog is currently selected.
 */
public static void tapNegativeButtonIn3ButtonDialog(InstrumentationTestCase testCase) {
  // The order of the buttons is reversed from ICS onwards
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    testCase.sendKeys("DPAD_RIGHT DPAD_RIGHT DPAD_CENTER");
  } else {
    testCase.sendKeys("DPAD_LEFT DPAD_LEFT DPAD_CENTER");
  }
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the neutral button of a currently displayed 3 button dialog. This method assumes
 * that a button of the dialog is currently selected.
 */
public static void tapNeutralButtonIn3ButtonDialog(InstrumentationTestCase testCase) {
  // The order of the buttons is reversed from ICS onwards
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    testCase.sendKeys("DPAD_RIGHT DPAD_CENTER");
  } else {
    testCase.sendKeys("DPAD_RIGHT DPAD_CENTER");
  }
}
项目:authenticator    文件:TestUtilities.java   
/**
 * Taps the positive button of a currently displayed 3 button dialog. This method assumes
 * that a button of the dialog is currently selected.
 */
public static void tapPositiveButtonIn3ButtonDialog(InstrumentationTestCase testCase) {
  // The order of the buttons is reversed from ICS onwards
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.ICE_CREAM_SANDWICH) {
    testCase.sendKeys("DPAD_LEFT DPAD_LEFT DPAD_CENTER");
  } else {
    testCase.sendKeys("DPAD_RIGHT DPAD_RIGHT DPAD_CENTER");
  }
}
项目:authenticator    文件:TestUtilities.java   
public static Point getCenterOfViewOnScreen(
    InstrumentationTestCase instr, View view) {
  int[] location = new int[2];
  view.getLocationOnScreen(location);
  int width = view.getWidth();
  int height = view.getHeight();
  final int center_x = location[0] + width / 2;
  final int center_y = location[1] + height / 2;
  return new Point(center_x, center_y);
}
项目:Android-ObservableScrollView-master    文件:UiTestUtils.java   
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();
}
项目:Android-ObservableScrollView-master    文件:UiTestUtils.java   
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);
}
项目:Android-ObservableScrollView-master    文件:UiTestUtils.java   
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);
}
项目:transistor    文件:MockitoUtil.java   
/**
 * Sets up Mockito for an instrumentation test.
 *
 * @param instrumentationTestCase The instrumentation test case class.
 */
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);
}