本文整理匯總了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