当前位置: 首页>>代码示例>>Java>>正文


Java InstrumentationTestCase类代码示例

本文整理汇总了Java中android.test.InstrumentationTestCase的典型用法代码示例。如果您正苦于以下问题:Java InstrumentationTestCase类的具体用法?Java InstrumentationTestCase怎么用?Java InstrumentationTestCase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


InstrumentationTestCase类属于android.test包,在下文中一共展示了InstrumentationTestCase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: setUpToFindComponet

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 *
 */
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;
        }

    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:WeexUiTestCaseTCAHrefEvent.java

示例2: setUpToFindComponet

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 *
 */
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;
        }

    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:WeexUiTestCaseTCAHrefUpdate.java

示例3: findTargetComponetIfNotFound

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 *
 */
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);
    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:21,代码来源:WeexUiTestCaseTCAHrefEvent.java

示例4: findTargetComponetIfNotFound

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 *
 */
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);
    }
}
 
开发者ID:amap-demo,项目名称:weex-3d-map,代码行数:22,代码来源:WeexUiTestCaseTCAHrefStyle.java

示例5: tapPreference

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:27,代码来源:TestUtilities.java

示例6: saveAndRestoreInstanceState

import android.test.InstrumentationTestCase; //导入依赖的package包/类
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();
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:14,代码来源:UiTestUtils.java

示例7: swipeHorizontally

import android.test.InstrumentationTestCase; //导入依赖的package包/类
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);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:16,代码来源:UiTestUtils.java

示例8: swipeVertically

import android.test.InstrumentationTestCase; //导入依赖的package包/类
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);
}
 
开发者ID:LeMinhAn,项目名称:AndroidObservableScrollView-master,代码行数:16,代码来源:UiTestUtils.java

示例9: tapDialogNegativeButton

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:15,代码来源:TestUtilities.java

示例10: tapDialogPositiveButton

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:15,代码来源:TestUtilities.java

示例11: tapNegativeButtonIn3ButtonDialog

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:13,代码来源:TestUtilities.java

示例12: tapNeutralButtonIn3ButtonDialog

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:13,代码来源:TestUtilities.java

示例13: tapPositiveButtonIn3ButtonDialog

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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");
  }
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:13,代码来源:TestUtilities.java

示例14: getCenterOfViewOnScreen

import android.test.InstrumentationTestCase; //导入依赖的package包/类
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);
}
 
开发者ID:ocdtrekkie,项目名称:authenticator,代码行数:11,代码来源:TestUtilities.java

示例15: setUpMockito

import android.test.InstrumentationTestCase; //导入依赖的package包/类
/**
 * 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);
}
 
开发者ID:y20k,项目名称:transistor,代码行数:12,代码来源:MockitoUtil.java


注:本文中的android.test.InstrumentationTestCase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。