आप एक एमुलेटर है, सिर्फ परीक्षण के इन प्रकार के लिए, एंड्रॉयड Marshmallow (एपीआई 23) के साथ उपयोग कर सकते हैं।
उदाहरण के लिए:
public void testCheckNotification_2() throws IOException, InterruptedException, GcmException
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
GcmResponse gcmResponse = endPointImp.sendGcmMulticastRequestImp(getGcmMultiRequest());
assertThat(gcmResponse.getSuccess(), is(1));
Thread.sleep(2000);
assertThat(mManager.getActiveNotifications().length, is(1));
StatusBarNotification barNotification = mManager.getActiveNotifications()[0];
assertThat(barNotification.getId(), is(INCIDENCIA.getTitleRsc()));
// We check the pending intent.
PendingIntent pendingIntent = barNotification.getNotification().contentIntent;
assertThat(pendingIntent.getCreatorPackage(), is(GcmRequest.PACKAGE_DIDEKINDROID));
}
}
महत्वपूर्ण हिस्सा NotificationManager (mManager) करने के लिए कॉल करें कि यह Google FCM http समाप्ति बिंदु को एक बहुस्त्र्पीय संदेश भेजने के बाद सक्रिय सूचना की जांच करने के लिए है।
स्रोत
2016-06-08 15:55:24
रोबोटियम नामक एक परीक्षण ढांचा है, लेकिन मुझे नहीं पता कि यह अधिसूचनाओं का समर्थन करता है या नहीं। लेकिन यदि मानक जूनिट लिब इसका समर्थन नहीं करता है, तो आप वहां शायद जांच सकते हैं। http://code.google.com/p/robotium/ –