当前位置: 首页>>代码示例>>Java>>正文


Java ShadowIntent类代码示例

本文整理汇总了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));
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:24,代码来源:RemindersActivityTest.java

示例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));
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:19,代码来源:GroceryStoreListViewHolderTest.java

示例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());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:20,代码来源:GroceryStoresActivityTest.java

示例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()));
}
 
开发者ID:SIGLUS,项目名称:lmis-moz-mobile,代码行数:20,代码来源:RnRFormListActivityTest.java

示例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();
    }
 
开发者ID:ylogx,项目名称:CCDroid,代码行数:17,代码来源:ListViewItemClickListenerTest.java

示例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());
}
 
开发者ID:bangarharshit,项目名称:Oleaster,代码行数:9,代码来源:MainActivityTestNormal.java

示例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());
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:8,代码来源:DashboardActivityTest.java

示例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());
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:8,代码来源:DashboardActivityTest.java

示例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());
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:8,代码来源:LoginActivityTest.java

示例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());
}
 
开发者ID:Welloculus,项目名称:MobileAppForPatient,代码行数:8,代码来源:LoginActivityTest.java

示例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();
}
 
开发者ID:Smart-Studio,项目名称:device-info,代码行数:14,代码来源:DashboardActivityUnitTest.java

示例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();
}
 
开发者ID:Smart-Studio,项目名称:device-info,代码行数:11,代码来源:AboutActivityUnitTest.java

示例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());
}
 
开发者ID:Nilhcem,项目名称:bblfr-android,代码行数:15,代码来源:NavigationDrawerActivityTest.java

示例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());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:15,代码来源:GroceryStoreManagerTest.java

示例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());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:12,代码来源:GroceryStoreNotificationManagerTest.java


注:本文中的org.robolectric.shadows.ShadowIntent类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。