本文整理匯總了Java中org.robolectric.shadows.ShadowActivity.getNextStartedActivity方法的典型用法代碼示例。如果您正苦於以下問題:Java ShadowActivity.getNextStartedActivity方法的具體用法?Java ShadowActivity.getNextStartedActivity怎麽用?Java ShadowActivity.getNextStartedActivity使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.robolectric.shadows.ShadowActivity
的用法示例。
在下文中一共展示了ShadowActivity.getNextStartedActivity方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: should_start_url_intent
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_start_url_intent() {
// Given
String url = "geo:22.5430883,114.1043205";
RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), ShadowResolveInfo.newResolveInfo("", "", ""));
// When
boolean result = Intents.startUri(activity, url);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertThat(result).isTrue();
assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(startedIntent.getData().toString()).isEqualTo(url);
}
示例2: should_return_false_when_nothing_on_the_device_can_open_the_uri
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_return_false_when_nothing_on_the_device_can_open_the_uri() {
// Given
String url = "http://www.google.com";
RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), (ResolveInfo) null);
// When
boolean result = Intents.startUri(activity, url);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertThat(result).isFalse();
assertThat(startedIntent).isNull();
}
示例3: should_start_external_uri
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_start_external_uri() {
// Given
String url = "http://www.google.com";
RobolectricPackageManager rpm = (RobolectricPackageManager) RuntimeEnvironment.application.getPackageManager();
rpm.addResolveInfoForIntent(new Intent(Intent.ACTION_VIEW, Uri.parse(url)), ShadowResolveInfo.newResolveInfo("", "", ""));
// When
Intents.startExternalUrl(activity, url);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertThat(startedIntent.getAction()).isEqualTo(Intent.ACTION_VIEW);
assertThat(startedIntent.getData().toString()).isEqualTo(url);
}
示例4: startAsViewClickEdit
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void startAsViewClickEdit() throws Exception
{
ActivityController activityController = setupActivity("budget", "", true, false);
Activity activity = (Activity)activityController.get();
shadowOf(activity).clickMenuItem(R.id.action_edit);
ShadowActivity shadowActivity = shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ComponentName name = startedIntent.getComponent();
assertNotNull(name);
assertEquals("protect.budgetwatch/.TransactionViewActivity", name.flattenToShortString());
Bundle bundle = startedIntent.getExtras();
assertNotNull(bundle);
assertEquals(DBHelper.TransactionDbIds.EXPENSE, bundle.getInt("type", -1));
assertEquals(1, bundle.getInt("id", -1));
assertEquals(true, bundle.getBoolean("update", false));
assertEquals(false, bundle.getBoolean("view", false));
}
示例5: testClickAdd
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void testClickAdd()
{
ActivityController activityController = Robolectric.buildActivity(BudgetActivity.class).create();
Activity activity = (Activity)activityController.get();
activityController.start();
activityController.resume();
activityController.visible();
shadowOf(activity).clickMenuItem(R.id.action_add);
ShadowActivity shadowActivity = shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ComponentName name = startedIntent.getComponent();
assertNotNull(name);
assertEquals("protect.budgetwatch/.BudgetViewActivity", name.flattenToShortString());
Bundle bundle = startedIntent.getExtras();
assertNull(bundle);
}
示例6: should_send_email_intent_when_clicking_on_button_to_contact_the_bagger
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_send_email_intent_when_clicking_on_button_to_contact_the_bagger() {
// Given
Context c = RuntimeEnvironment.application;
Button button = new Button(c);
button.setTag("[email protected]");
// When
view.onInviteButtonClicked(button);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(Robolectric.setupActivity(Activity.class));
Intent intent = shadowActivity.getNextStartedActivity();
Intent mailExtra = intent.getParcelableExtra(Intent.EXTRA_INTENT);
assertThat(intent.getStringExtra(Intent.EXTRA_TITLE)).isEqualTo(c.getString(R.string.baggers_list_contact_chooser_title));
assertThat(mailExtra.getData().getScheme()).isEqualTo("mailto");
assertThat(mailExtra.getStringExtra(Intent.EXTRA_SUBJECT)).isEqualTo(c.getString(R.string.baggers_list_contact_email_subject));
assertThat(mailExtra.getData().getSchemeSpecificPart()).isEqualTo("[email protected]");
}
示例7: should_start_baggers_list_activity_when_city_is_selected
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_start_baggers_list_activity_when_city_is_selected() {
// Given
City city = new City();
city.name = "Paris";
city.lat = 42d;
city.lng = 1d;
// When
activity.onCitySelected(city);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent intent = shadowActivity.getNextStartedActivity();
assertThat(intent.getComponent().getClassName()).isEqualTo(BaggersListActivity.class.getName());
assertThat(((City) intent.getParcelableExtra("mCity")).name).isEqualTo("Paris");
}
示例8: should_start_email_intent
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void should_start_email_intent() {
// Given
String title = "Sending email...";
String recipient = "[email protected]";
String subject = "Hello!";
// When
IntentUtils.startEmailIntent(activity, title, recipient, subject);
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent intent = shadowActivity.getNextStartedActivity();
Intent mailExtra = intent.getParcelableExtra(Intent.EXTRA_INTENT);
assertThat(intent.getStringExtra(Intent.EXTRA_TITLE)).isEqualTo(title);
assertThat(mailExtra.getData().getScheme()).isEqualTo("mailto");
assertThat(mailExtra.getStringExtra(Intent.EXTRA_SUBJECT)).isEqualTo(subject);
assertThat(mailExtra.getData().getSchemeSpecificPart()).isEqualTo(recipient);
}
示例9: testShouldOpenUrl
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Ignore
@Test public void testShouldOpenUrl() throws Exception {
Activity activity = Robolectric.buildActivity(MainActivity.class).create().get();
// listener.onItemClick(mock(AdapterView.class), mock(View.class), position, 1);
clickOnOpenButton();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
assertThat(shadowIntent.getAction(), is(Intent.ACTION_VIEW));
assertThat(shadowIntent.getData(), is(Uri.parse(url)));
// ArgumentCaptor<Intent> argumentCaptor = ArgumentCaptor.forClass(Intent.class);
// verify(context).startActivity(argumentCaptor.capture());
// Intent intent = argumentCaptor.getValue();
}
示例10: execute_whenNoUberApp_shouldPointToMobileSite
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void execute_whenNoUberApp_shouldPointToMobileSite() throws IOException {
String expectedUri = readUriResourceWithUserAgentParam("src/test/resources/deeplinkuris/no_app_installed",
USER_AGENT_DEEPLINK);
Activity activity = Robolectric.setupActivity(Activity.class);
ShadowActivity shadowActivity = shadowOf(activity);
RideParameters rideParameters = new RideParameters.Builder().build();
RequestDeeplink requestDeeplink = new RequestDeeplink.Builder(activity)
.setRideParameters(rideParameters)
.setSessionConfiguration(new SessionConfiguration.Builder().setClientId("clientId").build())
.build();
requestDeeplink.execute();
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertEquals(expectedUri, startedIntent.getData().toString());
}
示例11: execute_whenUberAppInsalled_shouldPointToUberApp
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void execute_whenUberAppInsalled_shouldPointToUberApp() throws IOException {
String expectedUri = readUriResourceWithUserAgentParam("src/test/resources/deeplinkuris/just_client_provided",
USER_AGENT_DEEPLINK);
Activity activity = Robolectric.setupActivity(Activity.class);
ShadowActivity shadowActivity = shadowOf(activity);
RobolectricPackageManager packageManager = RuntimeEnvironment.getRobolectricPackageManager();
PackageInfo uberPackage = new PackageInfo();
uberPackage.packageName = UBER_PACKAGE_NAME;
packageManager.addPackage(uberPackage);
RideParameters rideParameters = new RideParameters.Builder().build();
RequestDeeplink requestDeeplink = new RequestDeeplink.Builder(activity)
.setRideParameters(rideParameters)
.setSessionConfiguration(new SessionConfiguration.Builder().setClientId("clientId").build())
.build();
requestDeeplink.execute();
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertEquals(expectedUri, startedIntent.getData().toString());
}
示例12: shouldGotoEmergencyPage
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void shouldGotoEmergencyPage() throws Exception {
LMISTestApp.getInstance().setCurrentTimeMillis(DateUtil.parseString("2015-05-17 17:30:00", DateUtil.DATE_TIME_FORMAT).getTime());
Observable<Boolean> value = Observable.create(new Observable.OnSubscribe<Boolean>() {
@Override
public void call(Subscriber<? super Boolean> subscriber) {
subscriber.onNext(false);
}
});
when(mockedPresenter.hasMissedPeriod()).thenReturn(value);
rnRFormListActivity.checkAndGotoEmergencyPage();
ShadowActivity shadowActivity = shadowOf(rnRFormListActivity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
MatcherAssert.assertThat(shadowIntent.getComponent().getClassName(), equalTo(SelectEmergencyProductsActivity.class.getName()));
}
示例13: whenLocationIsEnabledItShouldGoToLogin
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void whenLocationIsEnabledItShouldGoToLogin() throws Exception {
// given
String expectedActivity = LoginActivity.class.getName();
shadowLocationManager.setProviderEnabled(LocationManager.GPS_PROVIDER, true);
welcomeActivity = Robolectric.setupActivity(WelcomeActivity.class);
ShadowActivity shadowActivity = shadowOf(welcomeActivity);
// when
welcomeActivity.onResume();
Intent startedIntent = shadowActivity.getNextStartedActivity();
String result = startedIntent.getComponent().getClassName();
// then
assertEquals(expectedActivity, result);
}
示例14: clickWithIntent
import org.robolectric.shadows.ShadowActivity; //導入方法依賴的package包/類
@Test
public void clickWithIntent() {
MyActivity activity = new MyActivity();
TestMenu testMenu = new TestMenu(activity);
testMenu.add(0, 10, 0, org.robolectric.R.string.ok);
TestMenuItem testMenuItem = (TestMenuItem) testMenu.findItem(10);
Assert.assertNull(testMenuItem.getIntent());
Intent intent = new Intent(activity, MyActivity.class);
testMenuItem.setIntent(intent);
testMenuItem.click();
Assert.assertNotNull(testMenuItem);
ShadowActivity shadowActivity = Robolectric.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
assertNotNull(startedIntent);
}
示例15: 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();
}