本文整理汇总了Java中com.twofortyfouram.test.ui.activity.ActivityTestUtil类的典型用法代码示例。如果您正苦于以下问题:Java ActivityTestUtil类的具体用法?Java ActivityTestUtil怎么用?Java ActivityTestUtil使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ActivityTestUtil类属于com.twofortyfouram.test.ui.activity包,在下文中一共展示了ActivityTestUtil类的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: testOldSetting
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testOldSetting() throws Throwable {
final Activity activity = getActivity();
/*
* It is necessary to call this manually; the test case won't call
* onPostCreate() for us :-(
*/
getActivity().onPostCreateWithPreviousResult(
getActivity().getIntent().getBundleExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE),
getActivity().getIntent().getStringExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB));
assertMessageAutoSync("I am a toast message!"); //$NON-NLS-1$
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode
(activity));
}
开发者ID:twofortyfouram,项目名称:android-toast-setting-plugin-for-locale,代码行数:23,代码来源:EditActivityTest.java
示例2: assertActivityResult
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Asserts the Activity result is correct.
* <p/>
* {@link Activity#finish()} must be called prior to calling this method.
*
* @param bundle The bundle to verify exists. Null indicates that no bundle
* should be present (not that a null bundle should be present).
* @param blurb The blurb to verify exists. Null indicates that no blurb
* should be present (not that a null blurb should be present).
*/
private void assertActivityResult(final int resultCode, @Nullable final Bundle bundle,
@Nullable final String blurb) {
final Activity activity = getActivity();
assertEquals(resultCode, ActivityTestUtil.getActivityResultCodeSync(getInstrumentation(), activity));
if (Activity.RESULT_OK == resultCode) {
final Intent result = ActivityTestUtil.getActivityResultDataSync(getInstrumentation(), activity);
assertNotNull(result);
final Bundle extras = result.getExtras();
BundleAssertions.assertKeyCount(extras, 2);
BundleAssertions.assertHasString(extras,
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB, blurb);
final Bundle pluginBundle = extras
.getBundle(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
assertTrue(BundleComparer.areBundlesEqual(bundle, pluginBundle));
} else if (Activity.RESULT_CANCELED == resultCode) {
assertNull(ActivityTestUtil.getActivityResultDataSync(getInstrumentation(), activity));
}
}
开发者ID:twofortyfouram,项目名称:android-plugin-client-sdk-for-locale,代码行数:34,代码来源:AppCompatPluginActivityImplTest.java
示例3: assertActivityResult
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Asserts the Activity result is correct.
* <p/>
* {@link android.app.Activity#finish()} must be called prior to calling this method.
*
* @param bundle The bundle to verify exists. Null indicates that no bundle
* should be present (not that a null bundle should be present).
* @param blurb The blurb to verify exists. Null indicates that no blurb
* should be present (not that a null blurb should be present).
*/
private void assertActivityResult(final int resultCode, @Nullable final Bundle bundle,
@Nullable final String blurb) {
final Activity activity = getActivity();
assertEquals(resultCode, ActivityTestUtil.getActivityResultCodeSync(getInstrumentation(), activity));
if (Activity.RESULT_OK == resultCode) {
final Intent result = ActivityTestUtil.getActivityResultDataSync(getInstrumentation(), activity);
assertNotNull(result);
final Bundle extras = result.getExtras();
BundleAssertions.assertKeyCount(extras, 2);
BundleAssertions.assertHasString(extras,
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB, blurb);
final Bundle pluginBundle = extras
.getBundle(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
assertTrue(BundleComparer.areBundlesEqual(bundle, pluginBundle));
} else if (Activity.RESULT_CANCELED == resultCode) {
assertNull(ActivityTestUtil.getActivityResultDataSync(getInstrumentation(), activity));
}
}
开发者ID:twofortyfouram,项目名称:android-plugin-client-sdk-for-locale,代码行数:34,代码来源:FragmentPluginActivityImplTest.java
示例4: testEditOldConditionOff
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testEditOldConditionOff() throws Throwable {
/*
* It is necessary to call this manually; the test case won't call
* onPostCreate() for us :-(
*/
getActivity().onPostCreateWithPreviousResult(
getActivity().getIntent().getBundleExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE),
getActivity().getIntent().getStringExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB));
assertSelectedPositionAutoSync(R.string.list_off);
getActivity().finish();
assertEquals(Activity.RESULT_CANCELED,
ActivityTestUtil.getActivityResultCode(getActivity()));
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:20,代码来源:EditActivityTest.java
示例5: testEditOldConditionOn
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testEditOldConditionOn() throws Throwable {
/*
* It is necessary to call this manually; the test case won't call
* onPostCreate() for us :-(
*/
getActivity().onPostCreateWithPreviousResult(
getActivity().getIntent().getBundleExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE),
getActivity().getIntent().getStringExtra(
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB));
assertSelectedPositionAutoSync(R.string.list_on);
getActivity().finish();
assertEquals(Activity.RESULT_CANCELED,
ActivityTestUtil.getActivityResultCode(getActivity()));
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:20,代码来源:EditActivityTest.java
示例6: testNewSettingCancel
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testNewSettingCancel() throws Throwable {
final Activity activity = getActivity();
assertMessageAutoSync(""); //$NON-NLS-1$
assertHintAutoSync(mTargetContext.getString(R.string.message_hint));
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode(activity));
}
开发者ID:twofortyfouram,项目名称:android-toast-setting-plugin-for-locale,代码行数:13,代码来源:EditActivityTest.java
示例7: testBadBundle
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Verifies the Activity properly handles a bundle with a bad value embedded in it.
*/
@MediumTest
@UiThreadTest
public void testBadBundle() throws Throwable {
final Activity activity = getActivity();
assertMessageAutoSync(""); //$NON-NLS-1$
assertHintAutoSync(mTargetContext.getString(R.string.message_hint));
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode
(activity));
}
开发者ID:twofortyfouram,项目名称:android-toast-setting-plugin-for-locale,代码行数:16,代码来源:EditActivityTest.java
示例8: assertActivityResultAutoSync
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Asserts the Activity result contains the expected values for the given display state.
*
* @param message The message the plug-in is supposed to show.
*/
private void assertActivityResultAutoSync(final String message) throws Throwable {
final Activity activity = getActivity();
final Runnable runnable = new Runnable() {
public void run() {
activity.finish();
assertEquals(Activity.RESULT_OK, ActivityTestUtil.getActivityResultCode(activity));
final Intent result = ActivityTestUtil.getActivityResultData(activity);
assertNotNull(result);
final Bundle extras = result.getExtras();
assertNotNull(extras);
assertEquals(
String.format(
"Extras should only contain %s and %s but actually contain %s",
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE,
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB,
extras.keySet()), 2, extras.keySet() //$NON-NLS-1$
.size());
assertFalse(TextUtils.isEmpty(extras
.getString(com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB)));
final Bundle pluginBundle = extras
.getBundle(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
assertNotNull(pluginBundle);
assertTrue(PluginBundleValues.isBundleValid(pluginBundle));
assertEquals(message,
pluginBundle.getString(PluginBundleValues.BUNDLE_EXTRA_STRING_MESSAGE));
}
};
autoSyncRunnable(runnable);
}
开发者ID:twofortyfouram,项目名称:android-toast-setting-plugin-for-locale,代码行数:43,代码来源:EditActivityTest.java
示例9: testNewCondition_cancel_result
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Tests creation of a new condition, that the UI is initialized to the
* right state, and that nothing is saved.
*/
@MediumTest
@UiThreadTest
public void testNewCondition_cancel_result() throws Throwable {
final Activity activity = getActivity();
assertSelectedPositionAutoSync(AdapterView.INVALID_POSITION);
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode(activity));
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:16,代码来源:EditActivityTest.java
示例10: testBadBundleMissingExtra
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testBadBundleMissingExtra() throws Throwable {
final Activity activity = getActivity();
assertSelectedPositionAutoSync(AdapterView.INVALID_POSITION);
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode(activity));
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:11,代码来源:EditActivityTest.java
示例11: testBadBundleWrongType
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
@MediumTest
@UiThreadTest
public void testBadBundleWrongType() throws Throwable {
final Activity activity = getActivity();
assertSelectedPositionAutoSync(AdapterView.INVALID_POSITION);
activity.finish();
assertEquals(Activity.RESULT_CANCELED, ActivityTestUtil.getActivityResultCode(activity));
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:11,代码来源:EditActivityTest.java
示例12: assertActivityResultAutoSync
import com.twofortyfouram.test.ui.activity.ActivityTestUtil; //导入依赖的package包/类
/**
* Asserts the Activity result contains the expected values for the given
* display state.
*
* @param isDisplayOn True if the display is on, false if the display is
* off.
*/
private void assertActivityResultAutoSync(final boolean isDisplayOn) throws Throwable {
final Activity activity = getActivity();
final Runnable runnable = new Runnable() {
public void run() {
/*
* Verify finishing with text entry is saved
*/
activity.finish();
assertEquals(Activity.RESULT_OK, ActivityTestUtil.getActivityResultCode(activity));
final Intent result = ActivityTestUtil.getActivityResultData(activity);
assertNotNull(result);
final Bundle extras = result.getExtras();
assertNotNull(extras);
assertEquals(
String.format(
"Extras should only contain %s and %s but actually contain %s",
com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE,
com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB,
extras.keySet()), 2, extras.keySet() //$NON-NLS-1$
.size());
assertFalse(TextUtils.isEmpty(extras
.getString(com.twofortyfouram.locale.api.Intent.EXTRA_STRING_BLURB)));
// BundleTestHelper.assertSerializable(extras);
final Bundle pluginBundle = extras
.getBundle(com.twofortyfouram.locale.api.Intent.EXTRA_BUNDLE);
assertNotNull(pluginBundle);
/*
* The following are tests specific to this plug-in's bundle
*/
assertTrue(PluginBundleValues.isBundleValid(pluginBundle));
assertEquals(isDisplayOn,
pluginBundle.getBoolean(PluginBundleValues.BUNDLE_EXTRA_BOOLEAN_STATE));
}
};
autoSyncRunnable(runnable);
}
开发者ID:twofortyfouram,项目名称:android-display-condition-plugin-for-locale,代码行数:52,代码来源:EditActivityTest.java