• 如果您觉得本站非常有看点,那么赶紧使用Ctrl+D 收藏吧

Java ShadowPendingIntent类的典型用法和代码示例

java 2次浏览

本文整理汇总了Java中org.robolectric.shadows.ShadowPendingIntent的典型用法代码示例。如果您正苦于以下问题:Java ShadowPendingIntent类的具体用法?Java ShadowPendingIntent怎么用?Java ShadowPendingIntent使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。

ShadowPendingIntent类属于org.robolectric.shadows包,在下文中一共展示了ShadowPendingIntent类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: givenPlacesWhenProximityAlertIsAddedThenTheStorePendingIntentRequestCodeIsUnique

点赞 3

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void givenPlacesWhenProximityAlertIsAddedThenTheStorePendingIntentRequestCodeIsUnique() {
    Place place = createDefaultGooglePlace();
    Place place2 = new Place();
    place2.setLatitude(place.getLatitude()+1);
    place2.setLongitude(place.getLongitude());
    place2.setName("test 2");
    place2.setPlaceId("test_id2");
    List<Place> places = new ArrayList<Place>();
    places.add(place);
    places.add(place2);

    groceryStoreManager.addProximityAlerts(places);

    List<com.groceryreminder.shadows.ShadowLocationManager.ProximityAlert> proximityAlerts = shadowLocationManager.getProximityAlerts();
    assertEquals(places.size(), proximityAlerts.size());

    ShadowPendingIntent shadowPendingIntent1 = Shadows.shadowOf(proximityAlerts.get(0).getPendingIntent());
    ShadowPendingIntent shadowPendingIntent2 = Shadows.shadowOf(proximityAlerts.get(1).getPendingIntent());
    assertNotEquals(shadowPendingIntent1.getRequestCode(), shadowPendingIntent2.getRequestCode());
}
 

开发者ID:jameskbride,
项目名称:grocery-reminder,
代码行数:22,
代码来源:GroceryStoreManagerTest.java

示例2: verifyReturnsMainActivity

点赞 3

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
private void verifyReturnsMainActivity() {
    // Tapping on the summary should go to MainActivity
    for (Notification notification : mNotificationManager.getAllNotifications()) {
        if ((notification.flags & Notification.FLAG_GROUP_SUMMARY) != Notification.FLAG_GROUP_SUMMARY) {
            continue;
        }

        ShadowPendingIntent pendingIntent = Shadows.shadowOf(notification.contentIntent);

        // We're launching an activity
        assertTrue(pendingIntent.isActivityIntent());

        // There should be 1 intent. The root (MainActivity)
        assertEquals(1, pendingIntent.getSavedIntents().length);
        Intent mainActivity = pendingIntent.getSavedIntent();
        assertEquals(MainActivity.class.getCanonicalName(), mainActivity.getComponent().getClassName());
    }
}
 

开发者ID:Xlythe,
项目名称:AndroidTextManager,
代码行数:19,
代码来源:NotificationsTest.java

示例3: setAddsTheAlarmIntent

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void setAddsTheAlarmIntent() {
    repo.set(alarm);

    ShadowAlarmManager.ScheduledAlarm nextAlarm = shadowAlarmManager.getNextScheduledAlarm();
    ShadowPendingIntent shadowPendingIntent = shadowOf(nextAlarm.operation);

    Intent expectedIntent = new Intent(context, AlarmReceiver.class);
    expectedIntent.putExtra(Alarm.ALARM_ID_KEY, alarm.getId());

    assertEquals(triggerTime.getMillis(), nextAlarm.triggerAtTime);
    assertTrue(expectedIntent.filterEquals(shadowPendingIntent.getSavedIntent()));
    assertEquals(PendingIntent.FLAG_UPDATE_CURRENT, shadowPendingIntent.getFlags());
}
 

开发者ID:KevinLiddle,
项目名称:crockpod,
代码行数:15,
代码来源:AlarmServiceRepositoryTest.java

示例4: whenProximityAlertIsAddedThenThePendingIntentIsSetToBroadcast

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void whenProximityAlertIsAddedThenThePendingIntentIsSetToBroadcast() {
    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());

    assertTrue(shadowPendingIntent.isBroadcastIntent());
}
 

开发者ID:jameskbride,
项目名称:grocery-reminder,
代码行数:14,
代码来源:GroceryStoreManagerTest.java

示例5: whenProximityAlertIsAddedThenTheStorePendingIntentIsSet

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的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

示例6: whenProximityAlertIsAddedThenTheStorePendingIntentCancelsTheCurrentRequest

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void whenProximityAlertIsAddedThenTheStorePendingIntentCancelsTheCurrentRequest() {
    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());

    assertEquals(PendingIntent.FLAG_CANCEL_CURRENT, shadowPendingIntent.getFlags());
}
 

开发者ID:jameskbride,
项目名称:grocery-reminder,
代码行数:14,
代码来源:GroceryStoreManagerTest.java

示例7: whenProximityAlertIsAddedThenTheStorePendingIntentContainsTheStoreName

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void whenProximityAlertIsAddedThenTheStorePendingIntentContainsTheStoreName() {
    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());

    assertEquals(place.getName(), shadowPendingIntent.getSavedIntent().getStringExtra(ReminderContract.Locations.NAME));
}
 

开发者ID:jameskbride,
项目名称:grocery-reminder,
代码行数:14,
代码来源:GroceryStoreManagerTest.java

示例8: givenANotificationIsSentWhenTheNotificationIsActedOnThenTheRemindersActivityIsLaunched

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的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

示例9: verifyReturnsMessageActivity

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
private void verifyReturnsMessageActivity(long expectedThreadId) {
    for (Notification notification : mNotificationManager.getAllNotifications()) {
        ShadowPendingIntent pendingIntent = Shadows.shadowOf(notification.contentIntent);

        // We're launching an activity
        assertTrue(pendingIntent.isActivityIntent());

        // There should be 2 intents. The root (MainActivity) and the child (MessageActivity).
        assertEquals(2, pendingIntent.getSavedIntents().length);
        Intent mainActivity = pendingIntent.getSavedIntents()[0];
        Intent messageActivity = pendingIntent.getSavedIntents()[1];
        assertEquals(MainActivity.class.getCanonicalName(), mainActivity.getComponent().getClassName());
        assertEquals(MessageActivity.class.getCanonicalName(), messageActivity.getComponent().getClassName());

        // MessageActivity should have extras for the thread we care about
        // We don't care about the implementation (thread vs id).
        String threadId = messageActivity.getStringExtra(MessageActivity.EXTRA_THREAD_ID);
        Thread thread = messageActivity.getParcelableExtra(MessageActivity.EXTRA_THREAD);
        if (threadId != null) {
            assertEquals(Long.toString(expectedThreadId), threadId);
        } else if (thread != null) {
            assertEquals(Long.toString(expectedThreadId), thread.getId());
        } else {
            throw new IllegalStateException("No thread or thread id given");
        }
    }
}
 

开发者ID:Xlythe,
项目名称:AndroidTextManager,
代码行数:28,
代码来源:NotificationsTest.java

示例10: shouldRestartServiceUsingAlarmManagerWhenTaskRemoved

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
@Test
public void shouldRestartServiceUsingAlarmManagerWhenTaskRemoved() {
	when(mockedTimeProvider.getDate()).thenReturn(new Date(ANY_TIME));

	startSmsInterceptorService();
	smsRadarService.onTaskRemoved(ANY_INTENT);

	ArgumentCaptor<PendingIntent> pendingIntentArgumentCaptor = ArgumentCaptor.forClass(PendingIntent.class);
	verify(mockedAlarmManager).set(eq(AlarmManager.RTC_WAKEUP), eq(ANY_TIME + ONE_SECOND),
			pendingIntentArgumentCaptor.capture());
	PendingIntent capturedPendingIntent = pendingIntentArgumentCaptor.getValue();
	ShadowPendingIntent pendingIntent = Robolectric.shadowOf(capturedPendingIntent);
	ShadowIntent intent = Robolectric.shadowOf(pendingIntent.getSavedIntent());
	assertEquals(SmsRadarService.class, intent.getIntentClass());
}
 

开发者ID:tuenti,
项目名称:SmsRadar,
代码行数:16,
代码来源:SmsRadarServiceTest.java

示例11: shadowOf

点赞 2

import org.robolectric.shadows.ShadowPendingIntent; //导入依赖的package包/类
public static ShadowPendingIntent shadowOf(PendingIntent instance) {
  return (ShadowPendingIntent) shadowOf_(instance);
}
 

开发者ID:qx,
项目名称:FullRobolectricTestSample,
代码行数:4,
代码来源:Robolectric.java


版权声明:本文转自网络文章,转载此文章仅为分享知识,如有侵权,请联系管理员进行删除。
喜欢 (0)