本文整理汇总了Java中org.robolectric.shadows.ShadowIntent类的典型用法代码示例。如果您正苦于以下问题:Java ShadowIntent类的具体用法?Java ShadowIntent怎么用?Java ShadowIntent使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
ShadowIntent类属于org.robolectric.shadows包,在下文中一共展示了ShadowIntent类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: givenTheLoaderIsFinishedWhenTheShareButtonIsPressedThenTheLoadedListOfRemindersIsShared
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void givenTheLoaderIsFinishedWhenTheShareButtonIsPressedThenTheLoadedListOfRemindersIsShared() {
Reminder reminder = new Reminder(0, "test");
Reminder reminder2 = new Reminder(0, "test2");
Cursor mockCursor = mock(Cursor.class);
when(mockCursor.moveToNext()).thenReturn(true).thenReturn(true).thenReturn(false);
when(mockCursor.getLong(0)).thenReturn(reminder.getId()).thenReturn(reminder2.getId());
when(mockCursor.getString(1)).thenReturn(reminder.getText()).thenReturn(reminder2.getText());
ShadowCursorWrapper wrapper = new ShadowCursorWrapper();
wrapper.__constructor__(mockCursor);
CursorLoader cursorLoader = (CursorLoader)activity.onCreateLoader(0, null);
activity.onLoadFinished(cursorLoader, wrapper);
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
shadowActivity.clickMenuItem(R.id.action_share);
ShadowIntent shadowIntent = Shadows.shadowOf(shadowActivity.peekNextStartedActivity());
assertEquals(Intent.ACTION_CHOOSER, shadowIntent.getAction());
ShadowIntent shareIntent = Shadows.shadowOf((Intent) shadowIntent.getParcelableExtra("android.intent.extra.INTENT"));
assertEquals("text/plain", shareIntent.getType());
assertEquals("test\ntest2\n", shareIntent.getExtras().getString(Intent.EXTRA_TEXT));
}
示例2: givenAStoreIsBoundWhenTheStoreViewHolderIsClickedThenTheMapApplicationIsLaunched
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void givenAStoreIsBoundWhenTheStoreViewHolderIsClickedThenTheMapApplicationIsLaunched() {
RecyclerView recyclerView = getRecyclerView();
Context context = recyclerView.getContext();
View view = LayoutInflater.from(context).inflate(R.layout.store_viewholder, recyclerView, false);
double latitude = 0.0;
double longitude = 1.0;
GroceryStore store = new GroceryStore(ARBITRARY_STORE_NAME, 2414.02, latitude, longitude);
GroceryStoreListViewHolder viewHolder = new GroceryStoreListViewHolder(view);
viewHolder.bind(store);
viewHolder.onClick(view);
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
ShadowIntent shadowIntent = Shadows.shadowOf(shadowActivity.peekNextStartedActivity());
assertTrue(shadowIntent.getData().toString().contains("geo:" + latitude + "," + longitude));
}
示例3: givenStoresAreLoadedWhenAStoreIsClickedThenTheMapApplicationIsLaunched
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void givenStoresAreLoadedWhenAStoreIsClickedThenTheMapApplicationIsLaunched() {
ShadowCursorWrapper wrapper = createCursorWithDefaultReminder();
GroceryStoreManagerInterface groceryStoreManagerMock = getTestReminderModule().getGroceryStoreManager();
when(groceryStoreManagerMock.getCurrentLocation()).thenReturn(new Location(LocationManager.PASSIVE_PROVIDER));
CursorLoader cursorLoader = (CursorLoader)activity.onCreateLoader(0, null);
activity.onLoadFinished(cursorLoader, wrapper);
GroceryStoreListFragment groceryStoreListFragment = getGroceryStoreListFragment();
assertNotNull(groceryStoreListFragment);
RecyclerView listView = getRecyclerView(groceryStoreListFragment, R.id.stores_recycler_view);
listView.findViewHolderForAdapterPosition(0).itemView.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
ShadowIntent shadowIntent = Shadows.shadowOf(shadowActivity.peekNextStartedActivity());
assertEquals("geo:0.0,1.0?q=0.0,1.0(test)", shadowIntent.getData().toString());
}
示例4: shouldGotoEmergencyPage
import org.robolectric.shadows.ShadowIntent; //导入依赖的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()));
}
示例5: testShouldOpenUrl
import org.robolectric.shadows.ShadowIntent; //导入依赖的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();
}
示例6: buttonClick_startNextActivity
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void buttonClick_startNextActivity() {
button.performClick();
ShadowActivity shadowActivity = Shadows.shadowOf(mainActivity);
Intent intent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(intent);
Assert.assertEquals(SecondActivity.class, shadowIntent.getIntentClass());
}
示例7: testDeviceClick
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testDeviceClick() {
btnDeviceConnect.performClick();
Intent startedIntent = Shadows.shadowOf(activity).getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
junit.framework.Assert.assertEquals("deviceList has not been launched",DeviceListActivity2.class, shadowIntent.getIntentClass());
}
示例8: testReportClick
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testReportClick() {
btnGetReport.performClick();
Intent startedIntent = Shadows.shadowOf(activity).getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
Assert.assertEquals( "reportList activity ",ReportsActivity.class, shadowIntent.getIntentClass());
}
示例9: testsignUp
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testsignUp(){
activity.signUp(null);
Intent startedIntent = Shadows.shadowOf(activity).getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
Assert.assertEquals("register user has not been launched",RegisterUser.class, shadowIntent.getIntentClass());
}
示例10: testaboutApp
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testaboutApp(){
activity.forgotPassword(null);
Intent startedIntent = Shadows.shadowOf(activity).getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
Assert.assertEquals("forgot password has not been launched",ForgotPasswordActivity.class, shadowIntent.getIntentClass());
}
示例11: testOnOptionsItemSelectedAboutClicked
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testOnOptionsItemSelectedAboutClicked() throws Exception {
MenuItem item = mockMenuItem(R.id.about);
mActivity.onOptionsItemSelected(item);
ShadowActivity shadowActivity = shadowOf(mActivity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
assertThat(shadowIntent.getComponent().getClassName()).isEqualTo(AboutActivity.class.getName());
verify(mAnalytics).reportAboutTap();
verify(mFabricAnalytics).reportAboutTap();
}
示例12: testOnAttributionsClicked
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void testOnAttributionsClicked() throws Exception {
mActivity.onAttributionsClicked();
ShadowActivity shadowActivity = shadowOf(mActivity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = shadowOf(startedIntent);
assertThat(shadowIntent.getComponent().getClassName()).isEqualTo(AttributionsActivity.class.getName());
verify(mAnalytics).reportAttributionsTap();
verify(mFabricAnalytics).reportAttributionsTap();
}
示例13: when
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void should_start_baggers_list_activity_if_drawer_is_not_visible_on_back_pressed_and_current_activity_is_not_a_baggers_list_activity() {
// Given
when(drawer.isDrawerVisible(GravityCompat.START)).thenReturn(false);
// When
activity.onBackPressed();
// Then
ShadowActivity shadowActivity = Shadows.shadowOf(activity);
Intent startedIntent = shadowActivity.getNextStartedActivity();
ShadowIntent shadowIntent = Shadows.shadowOf(startedIntent);
Truth.assertThat(shadowIntent.getIntentClass().getName()).isEqualTo(BaggersListActivity.class.getName());
}
示例14: whenProximityAlertIsAddedThenTheStorePendingIntentIsSet
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void whenProximityAlertIsAddedThenTheStorePendingIntentIsSet() {
Place place = createDefaultGooglePlace();
List<Place> places = new ArrayList<Place>();
places.add(place);
groceryStoreManager.addProximityAlerts(places);
com.groceryreminder.shadows.ShadowLocationManager.ProximityAlert proximityAlert = shadowLocationManager.getProximityAlert(place.getLatitude(), place.getLongitude());
ShadowPendingIntent shadowPendingIntent = Shadows.shadowOf(proximityAlert.getPendingIntent());
ShadowIntent shadowIntent = Shadows.shadowOf(shadowPendingIntent.getSavedIntent());
assertEquals(GroceryReminderConstants.ACTION_STORE_PROXIMITY_EVENT, shadowIntent.getAction());
}
示例15: givenANotificationIsSentWhenTheNotificationIsActedOnThenTheRemindersActivityIsLaunched
import org.robolectric.shadows.ShadowIntent; //导入依赖的package包/类
@Test
public void givenANotificationIsSentWhenTheNotificationIsActedOnThenTheRemindersActivityIsLaunched() {
groceryStoreNotificationManager.sendNotification(buildIntentToListenFor());
ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));
ShadowPendingIntent shadowPendingIntent = Shadows.shadowOf(notification.getRealNotification().contentIntent);
ShadowIntent shadowIntent = Shadows.shadowOf(shadowPendingIntent.getSavedIntent());
assertEquals(RemindersActivity.class.getName(), shadowIntent.getComponent().getClassName());
}