• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java ShadowNotificationManager类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: whenANotificationIsSentThenTheTheNotificationIncludesTheStoreName

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheTheNotificationIncludesTheStoreName() {
    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);

    insertStoreLocation(shadowApplication);

    ShadowLocation.setDistanceBetween(new float[]{(float) GroceryReminderConstants.LOCATION_GEOFENCE_RADIUS_METERS});

    long currentTime = System.currentTimeMillis();
    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), currentTime);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    ShadowNotification shadowNotification = (ShadowNotification)Shadows.shadowOf(notification);
    assertTrue(((String) shadowNotification.getContentTitle()).contains(ARBITRARY_STORE_NAME));
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:17,代码来源:GroceryStoreNotificationManagerTest.java


示例2: insertStoreLocation

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
 public void givenAStoreNotificationHasBeenStoredWhenARequestToSendANotificationWithTheTheSameStoreIsReceivedBeforeTheMinimumUpdateTimeForTheSameStoreThenTheNotificationIsNotSent() {
    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);

    insertStoreLocation(shadowApplication);
    SharedPreferences sharedPreferences = shadowApplication.getSharedPreferences(shadowApplication.getString(R.string.reminder_pref_key), Context.MODE_PRIVATE);
    sharedPreferences.edit().putString(GroceryReminderConstants.LAST_NOTIFIED_STORE_KEY, ARBITRARY_STORE_NAME)
            .putLong(GroceryReminderConstants.LAST_NOTIFICATION_TIME_FOR_SAME_STORE, System.currentTimeMillis() - 1)
            .commit();

    ShadowLocation.setDistanceBetween(new float[]{(float) GroceryReminderConstants.LOCATION_GEOFENCE_RADIUS_METERS});

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();

    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), System.currentTimeMillis());

    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertNull(notification);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:20,代码来源:GroceryStoreNotificationManagerTest.java


示例3: whenANotificationIsSentThenTheNotificationShouldBeCreated

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheNotificationShouldBeCreated() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertNotNull(notification);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:11,代码来源:GroceryStoreNotificationManagerTest.java


示例4: whenANotificationIsSentThenTheSmallIconIsSet

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheSmallIconIsSet() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertEquals(R.drawable.ic_stat_maps_local_grocery_store, notification.icon);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:11,代码来源:GroceryStoreNotificationManagerTest.java


示例5: whenANotificationIsSentThenTheContentTitleIsSet

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheContentTitleIsSet() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));
    assertEquals(RuntimeEnvironment.application.getString(R.string.app_name) + ": " + ARBITRARY_STORE_NAME, notification.getContentTitle());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:11,代码来源:GroceryStoreNotificationManagerTest.java


示例6: whenANotificationIsSentThenTheContentTextIsSet

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheContentTextIsSet() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));
    assertEquals(RuntimeEnvironment.application.getString(R.string.reminder_notification), notification.getContentText());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:11,代码来源:GroceryStoreNotificationManagerTest.java


示例7: whenANotificationIsSentThenTheVibrationIsSet

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheVibrationIsSet() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));

    assertArrayEquals(GroceryReminderConstants.PROXIMITY_VIBRATION_PATTERN, notification.getRealNotification().vibrate);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:12,代码来源:GroceryStoreNotificationManagerTest.java


示例8: whenANotificationIsSentThenTheDefaultNotificationSoundPlays

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenANotificationIsSentThenTheDefaultNotificationSoundPlays() {
    Intent intent = buildIntentToListenFor();

    groceryStoreNotificationManager.sendNotification(intent);

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));

    assertEquals(Settings.System.DEFAULT_NOTIFICATION_URI, notification.getRealNotification().sound);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:12,代码来源:GroceryStoreNotificationManagerTest.java


示例9: whenThereAreNoStoresThenTheNotificationIsNotSent

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenThereAreNoStoresThenTheNotificationIsNotSent() {
    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();

    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);
    shadowApplication.getContentResolver().delete(ReminderContract.Locations.CONTENT_URI, null, null);

    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), System.currentTimeMillis());

    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertNull(notification);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:13,代码来源:GroceryStoreNotificationManagerTest.java


示例10: givenAStoreNotificationHasNotBeenSentWhenARequestToSendANotificationIsReceivedThenTheIsSent

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void givenAStoreNotificationHasNotBeenSentWhenARequestToSendANotificationIsReceivedThenTheIsSent() {
    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);

    insertStoreLocation(shadowApplication);
    ShadowLocation.setDistanceBetween(new float[]{(float) GroceryReminderConstants.LOCATION_GEOFENCE_RADIUS_METERS});

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();

    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), System.currentTimeMillis());

    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertNotNull(notification);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:15,代码来源:GroceryStoreNotificationManagerTest.java


示例11: whenNoRemindersExistThenNoNotificationIsSent

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenNoRemindersExistThenNoNotificationIsSent() {
    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);
    shadowApplication.getContentResolver().delete(ReminderContract.Reminders.CONTENT_URI, null, null);
    insertStoreLocation(shadowApplication);
    ShadowLocation.setDistanceBetween(new float[]{(float) GroceryReminderConstants.LOCATION_GEOFENCE_RADIUS_METERS});

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();

    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), System.currentTimeMillis());

    Notification notification = shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT);
    assertNull(notification);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:15,代码来源:GroceryStoreNotificationManagerTest.java


示例12: givenANotificationIsSentWhenTheNotificationIsActedOnThenTheRemindersActivityIsLaunched

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


示例13: givenANotificationIsSentWhenTheNotificationIsActedOnThenTheTheNotificationIsDismissed

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void givenANotificationIsSentWhenTheNotificationIsActedOnThenTheTheNotificationIsDismissed() {
    groceryStoreNotificationManager.sendNotification(buildIntentToListenFor());

    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();
    ShadowNotification notification = Shadows.shadowOf(shadowNotificationManager.getNotification(GroceryReminderConstants.NOTIFICATION_PROXIMITY_ALERT));

    assertTrue((notification.getRealNotification().flags & Notification.FLAG_AUTO_CANCEL) == Notification.FLAG_AUTO_CANCEL);
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:10,代码来源:GroceryStoreNotificationManagerTest.java


示例14: testShowBackgroundRunningNotification

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void testShowBackgroundRunningNotification() {
    HijackingNotification hijackingNotification = new HijackingNotification(RuntimeEnvironment.application);
    hijackingNotification.show();

    ShadowNotificationManager nm = shadowOf((NotificationManager) RuntimeEnvironment.application
            .getSystemService(Context.NOTIFICATION_SERVICE));
    Assert.assertNotNull(nm.getNotification(HijackingNotification.NOTIFICATION_ID));
}
 
开发者ID:HunkD,项目名称:Awwl,代码行数:10,代码来源:HijackingNotificationTest.java


示例15: testDismissBackgroundRunningNotification

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void testDismissBackgroundRunningNotification() {
    HijackingNotification hijackingNotification = new HijackingNotification(RuntimeEnvironment.application);
    hijackingNotification.show();
    hijackingNotification.dismiss();

    ShadowNotificationManager nm = shadowOf((NotificationManager) RuntimeEnvironment.application
            .getSystemService(Context.NOTIFICATION_SERVICE));
    Assert.assertNull(nm.getNotification(HijackingNotification.NOTIFICATION_ID));
}
 
开发者ID:HunkD,项目名称:Awwl,代码行数:11,代码来源:HijackingNotificationTest.java


示例16: shouldCreatePersistentNotification

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void shouldCreatePersistentNotification() throws Exception {
    mnc.createNewNotification("title", "content");
    NotificationManager notificationManager = (NotificationManager)
            ACTIVITY.getSystemService(Robolectric.application.NOTIFICATION_SERVICE);
    ShadowNotificationManager shadowManager = Robolectric.shadowOf(notificationManager);
    Notification notification = shadowManager.getAllNotifications().get(0);
    assertThat(Robolectric.shadowOf(notification).isOngoing()).isTrue();
}
 
开发者ID:mapzen,项目名称:open,代码行数:10,代码来源:MapzenNotificationCreatorTest.java


示例17: testNotification

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void testNotification() throws IOException {
    Call<HackerNewsItem> call = mock(Call.class);
    when(call.execute()).thenReturn(Response.success(new TestHnItem(1L) {
        @Override
        public boolean isStoryType() {
            return true;
        }

        @Override
        public String getRawUrl() {
            return "http://example.com";
        }

        @Override
        public long[] getKids() {
            return new long[]{2L, 3L};
        }
    }));
    when(TestRestServiceFactory.hnRestService.cachedItem(eq("1"))).thenReturn(call);
    Call<HackerNewsItem> kid1Call = mock(Call.class);
    when(kid1Call.execute()).thenReturn(Response.success(new TestHnItem(2L) {
        @Override
        public boolean isStoryType() {
            return false;
        }
    }));
    when(TestRestServiceFactory.hnRestService.cachedItem(eq("2"))).thenReturn(kid1Call);
    Call<HackerNewsItem> kid2Call = mock(Call.class);
    when(kid2Call.execute()).thenThrow(IOException.class);
    when(TestRestServiceFactory.hnRestService.cachedItem(eq("3"))).thenReturn(kid2Call);
    when(TestRestServiceFactory.hnRestService.networkItem(eq("3"))).thenReturn(kid2Call);

    PreferenceManager.getDefaultSharedPreferences(service)
            .edit()
            .putBoolean(service.getString(R.string.pref_offline_notification), true)
            .apply();
    syncScheduler.scheduleSync(service, "1");
    adapter.onPerformSync(mock(Account.class), getLastSyncExtras(), null, null, null);
    verify(readabilityClient).parse(any(), eq("http://example.com"),
            readabilityCallbackCaptor.capture());
    readabilityCallbackCaptor.getValue().onResponse("");

    ShadowNotificationManager notificationManager = shadowOf((NotificationManager) service
            .getSystemService(Context.NOTIFICATION_SERVICE));
    ProgressBar progress = shadowOf(notificationManager.getNotification(1))
            .getProgressBar();
    assertThat(progress.getProgress()).isEqualTo(3); // self + kid 1 + readability
    assertThat(progress.getMax()).isEqualTo(104); // self + 2 kids + readability + web

    shadowOf(adapter.syncDelegate.mWebView).getWebChromeClient()
            .onProgressChanged(adapter.syncDelegate.mWebView, 100);

    verify(kid2Call).enqueue(callbackCapture.capture());
    callbackCapture.getValue().onFailure(null, null);
    assertThat(notificationManager.getAllNotifications()).isEmpty();
}
 
开发者ID:hidroh,项目名称:materialistic,代码行数:58,代码来源:ItemSyncAdapterTest.java


示例18: getShadowNotificationManager

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
private ShadowNotificationManager getShadowNotificationManager() {
    return Shadows.shadowOf((NotificationManager)
            RuntimeEnvironment.application.getSystemService(Context.NOTIFICATION_SERVICE));
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:5,代码来源:GroceryStoreNotificationManagerTest.java


示例19: whenThereAreMultipleStoresNearbyThenOnlyOneNotificationIsSent

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
@Test
public void whenThereAreMultipleStoresNearbyThenOnlyOneNotificationIsSent() {
    ShadowNotificationManager shadowNotificationManager = getShadowNotificationManager();

    ShadowApplication shadowApplication = (ShadowApplication) Shadows.shadowOf(RuntimeEnvironment.application);

    insertStoreLocation(shadowApplication);
    insertStoreLocation(shadowApplication);

    ShadowLocation.setDistanceBetween(new float[]{(float) GroceryReminderConstants.LOCATION_GEOFENCE_RADIUS_METERS});

    groceryStoreNotificationManager.sendPotentialNotification(new Location(LocationManager.GPS_PROVIDER), System.currentTimeMillis());

    List<Notification> notifications = shadowNotificationManager.getAllNotifications();
    assertEquals(1, notifications.size());
}
 
开发者ID:jameskbride,项目名称:grocery-reminder,代码行数:17,代码来源:GroceryStoreNotificationManagerTest.java


示例20: shadowOf

import org.robolectric.shadows.ShadowNotificationManager; //导入依赖的package包/类
public static ShadowNotificationManager shadowOf(NotificationManager other) {
  return (ShadowNotificationManager) Robolectric.shadowOf_(other);
}
 
开发者ID:qx,项目名称:FullRobolectricTestSample,代码行数:4,代码来源:Robolectric.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java GetEntitySetUriInfo类代码示例发布时间:2022-05-22
下一篇:
Java ValidatableResponse类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap