當前位置: 首頁>>代碼示例>>Java>>正文


Java ShadowActivity.receiveResult方法代碼示例

本文整理匯總了Java中org.robolectric.shadows.ShadowActivity.receiveResult方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowActivity.receiveResult方法的具體用法?Java ShadowActivity.receiveResult怎麽用?Java ShadowActivity.receiveResult使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在org.robolectric.shadows.ShadowActivity的用法示例。


在下文中一共展示了ShadowActivity.receiveResult方法的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。

示例1: fillOutFormWithCaseUpdate

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
private void fillOutFormWithCaseUpdate() {
    StandardHomeActivity homeActivity = buildHomeActivityForFormEntryLaunch();

    ShadowActivity shadowActivity = Shadows.shadowOf(homeActivity);
    Intent formEntryIntent = shadowActivity.getNextStartedActivity();

    // make sure the form entry activity should be launched
    String intentActivityName = formEntryIntent.getComponent().getClassName();
    assertTrue(intentActivityName.equals(FormEntryActivity.class.getName()));

    ShadowActivity shadowFormEntryActivity = navigateFormEntry(formEntryIntent);

    // trigger CommCareHomeActivity.onActivityResult for the completion of
    // FormEntryActivity
    shadowActivity.receiveResult(formEntryIntent,
            shadowFormEntryActivity.getResultCode(),
            shadowFormEntryActivity.getResultIntent());
    assertStoredFroms();
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:20,代碼來源:FormRecordProcessingTest.java

示例2: launchFormEntryForSavedForm

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
private static void launchFormEntryForSavedForm(ShadowActivity homeActivityShadow,
                                                Intent savedFormsIntent,
                                                FormRecordListActivity savedFormsActivity) {
    ShadowEnvironment.setExternalStorageState(Environment.MEDIA_MOUNTED);

    ShadowActivity formRecordShadow = Shadows.shadowOf(savedFormsActivity);
    homeActivityShadow.receiveResult(savedFormsIntent,
            formRecordShadow.getResultCode(),
            formRecordShadow.getResultIntent());
    ShadowActivity.IntentForResult formEntryIntent =
            homeActivityShadow.getNextStartedActivityForResult();
    Robolectric.buildActivity(FormEntryActivity.class)
                    .withIntent(formEntryIntent.intent)
                    .create().start().resume().get();

    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();

    assertNotNull(FormEntryActivity.mFormController);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:21,代碼來源:FormRecordListActivityTest.java

示例3: emptyFileSelectionTest

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
 * Ensure user sees invalid path toast when the file browser doesn't return a path uri
 */
@Test
public void emptyFileSelectionTest() {
    MultimediaInflaterActivity multimediaInflaterActivity =
            Robolectric.buildActivity(MultimediaInflaterActivity.class)
                    .create().start().resume().get();

    ImageButton selectFileButton =
            (ImageButton)multimediaInflaterActivity.findViewById(
                    R.id.screen_multimedia_inflater_filefetch);
    selectFileButton.performClick();

    Intent fileSelectIntent = new Intent(Intent.ACTION_GET_CONTENT);
    fileSelectIntent.setType("application/zip");

    Intent emptyFileSelectResult = new Intent();

    ShadowActivity shadowActivity =
            Shadows.shadowOf(multimediaInflaterActivity);
    shadowActivity.receiveResult(fileSelectIntent,
            Activity.RESULT_OK,
            emptyFileSelectResult);

    Assert.assertEquals(Localization.get("file.invalid.path"),
            ShadowToast.getTextOfLatestToast());
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:29,代碼來源:MultimediaInflaterActivityTest.java

示例4: testHiddenRepeatAtEndOfForm

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
 * Test filling out and saving a form ending in a hidden repeat group. This
 * type of form exercises uncommon end-of-form code paths
 */
@Test
public void testHiddenRepeatAtEndOfForm() {
    ShadowActivity shadowActivity =
            ActivityLaunchUtils.buildHomeActivityForFormEntryLaunch("m0-f0");

    Intent formEntryIntent = shadowActivity.getNextStartedActivity();

    // make sure the form entry activity should be launched
    String intentActivityName = formEntryIntent.getComponent().getClassName();
    assertTrue(intentActivityName.equals(FormEntryActivity.class.getName()));

    ShadowActivity shadowFormEntryActivity = navigateFormEntry(formEntryIntent);

    // trigger CommCareHomeActivity.onActivityResult for the completion of
    // FormEntryActivity
    shadowActivity.receiveResult(formEntryIntent,
            shadowFormEntryActivity.getResultCode(),
            shadowFormEntryActivity.getResultIntent());
    assertStoredForms();
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:25,代碼來源:EndOfFormTest.java

示例5: invalidAppInstall

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
 * Test that trying to install an app with an invalid suite file results in
 * the appropriate error message and a pinned notification with more
 * details
 */
@Test
public void invalidAppInstall() {
    String invalidUpdateReference = "jr://resource/commcare-apps/update_tests/invalid_suite_update/profile.ccpr";

    // start the setup activity
    Intent setupIntent =
            new Intent(RuntimeEnvironment.application, CommCareSetupActivity.class);

    CommCareSetupActivity setupActivity =
            Robolectric.buildActivity(CommCareSetupActivity.class)
                    .withIntent(setupIntent).setup().get();

    // click the 'offline install' menu item
    ShadowActivity shadowActivity = Shadows.shadowOf(setupActivity);
    shadowActivity.clickMenuItem(CommCareSetupActivity.MENU_ARCHIVE);

    // make sure there are no pinned notifications
    NotificationManager notificationManager =
            (NotificationManager)RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE);
    Notification notification = Shadows.shadowOf(notificationManager).getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
    assertNull(notification);

    // mock receiving the offline app reference and start the install
    Intent referenceIntent = new Intent();
    referenceIntent.putExtra(InstallArchiveActivity.ARCHIVE_JR_REFERENCE, invalidUpdateReference);
    shadowActivity.receiveResult(shadowActivity.getNextStartedActivity(), Activity.RESULT_OK, referenceIntent);

    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();

    // assert that we get the right error message
    assertTrue(setupActivity.getErrorMessageToDisplay().contains(Localization.get("notification.install.invalid.title")));

    // check that a pinned notification was created for invalid update
    // NOTE: it is way more work to assert the notification body is correct, so skip over that
    notification = Shadows.shadowOf(notificationManager).getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
    assertNotNull(notification);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:44,代碼來源:CommCareSetupActivityTest.java

示例6: performFingerprintCallout

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
private void performFingerprintCallout() {
    // make entity list callout to 'fingerprint identification'
    entitySelectActivity.barcodeScanOnClickListener.onClick(null);

    // receive the (faked) callout result
    Callout identificationScanCallout = getEntitySelectCallout();
    Intent calloutIntent = EntitySelectCalloutSetup.buildCalloutIntent(
            identificationScanCallout,
            entitySelectActivity.evalContext());
    Intent responseIntent = buildIdentificationResultIntent();
    ShadowActivity shadowEntitySelect = Shadows.shadowOf(entitySelectActivity);
    shadowEntitySelect.receiveResult(calloutIntent, Activity.RESULT_OK, responseIntent);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:14,代碼來源:EntityListCalloutDataTest.java

示例7: invalidUpdateTest

import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
/**
 * Use the update activity to update to a ccz with an invalid suite file.
 * Assert that an error is shown and pinned notification is created w/ more details
 */
@Test
public void invalidUpdateTest() {
    String invalidUpdateReference =
            "jr://resource/commcare-apps/update_tests/invalid_suite_update/profile.ccpr";

    // start the update activity
    Intent updateActivityIntent =
            new Intent(RuntimeEnvironment.application, UpdateActivity.class);

    UpdateActivity updateActivity =
            Robolectric.buildActivity(UpdateActivity.class)
                    .withIntent(updateActivityIntent).setup().get();

    // click the 'offline install' menu item
    ShadowActivity shadowActivity = Shadows.shadowOf(updateActivity);
    shadowActivity.clickMenuItem(UpdateActivity.MENU_UPDATE_FROM_CCZ);

    // Make sure there are no pinned notifications before we start
    NotificationManager notificationManager =
            (NotificationManager)RuntimeEnvironment.application
                    .getSystemService(Context.NOTIFICATION_SERVICE);
    notificationManager.cancel(CommCareNoficationManager.MESSAGE_NOTIFICATION);
    Notification notification = Shadows.shadowOf(notificationManager)
            .getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
    assertNull(notification);

    // mock receiving the offline app reference and start the update
    Intent referenceIntent = new Intent();
    referenceIntent.putExtra(InstallArchiveActivity.ARCHIVE_JR_REFERENCE, invalidUpdateReference);
    shadowActivity.receiveResult(shadowActivity.getNextStartedActivity(), Activity.RESULT_OK,
            referenceIntent);

    Robolectric.flushBackgroundThreadScheduler();
    Robolectric.flushForegroundThreadScheduler();

    // assert that we get the right error message
    String errorMessage = (String)((TextView)updateActivity
            .findViewById(R.id.update_progress_text)).getText();
    assertEquals(Localization.get("updates.check.failed"), errorMessage);

    // check that a pinned notification was created for invalid update
    // NOTE: it is way more work to assert the notification body is correct, so skip over that
    notification = Shadows.shadowOf(notificationManager)
            .getNotification(CommCareNoficationManager.MESSAGE_NOTIFICATION);
    assertNotNull(notification);
}
 
開發者ID:dimagi,項目名稱:commcare-android,代碼行數:51,代碼來源:UpdateActivityTest.java


注:本文中的org.robolectric.shadows.ShadowActivity.receiveResult方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。