package cn.six.robolectric.notification;

import android.app.Notification;
import android.app.NotificationManager;
import android.content.Context;

import org.junit.Before;
import org.junit.Test;
import org.robolectric.shadows.ShadowNotificationManager;

import ca.six.aut.robolectric.BaseRoboTestCase;
import static junit.framework.Assert.assertEquals;
import static org.robolectric.Shadows.shadowOf;

public class NotificationUtilsTest extends BaseRoboTestCase {

    private ShadowNotificationManager shadow;

    @Before
    public void setUp() throws Exception {
        NotificationManager mgr = (NotificationManager)app.getSystemService(Context.NOTIFICATION_SERVICE);
        shadow = shadowOf(mgr);
    }

    @Test
    public void call_sendNotification(){
        assertEquals(shadow.size(), 0);

        NotificationUtils utils = new NotificationUtils();
        utils.showNotification(app);
        assertEquals(shadow.size(), 1);
    }

    @Test
    public void call_actionAllSend(){
        Notification notification = getNotification();
        assertEquals(notification.actions.length, 3);
    }

    private Notification getNotification() {NotificationUtils utils = new NotificationUtils();
        utils.showNotification(app);
        return shadow.getAllNotifications().get(0);
    }



}
@@ -127,22 +127,87 @@
 oid.
-content.Contex
+app.PendingIntent;%0Aimport android.content.Context;%0Aimport android.content.Inten
 t;%0A%0A
@@ -1363,10 +1363,1061 @@
     %7D%0A%0A%0A
+    @Test%0A    public void call_action1GoesB()%7B%0A        Notification notification = getNotification();%0A        // %E8%AF%B4%E6%98%AF%E6%9C%89API 19%E6%89%8D%E6%9C%89%E7%9A%84%E6%96%B9%E6%B3%95%E3%80%82 %E4%BD%86%E8%BF%99%E6%98%AF%E6%B5%8B%E8%AF%95%E6%96%B9%E6%B3%95%EF%BC%8C %E6%89%80%E4%BB%A5%E6%B2%A1%E4%BA%8B%E7%9A%84%0A        PendingIntent pendingIntent = notification.actions%5B0%5D.actionIntent;%0A        Intent action1Intent = shadowOf(pendingIntent).getSavedIntent();%0A        String nextClasName = action1Intent.getComponent().getClassName();%0A        assertEquals(nextClasName, Notification_B.class.getName());%0A%0A        String value = action1Intent.getStringExtra(%22key%22);%0A        assertEquals(value, %22This is B%22);%0A    %7D%0A%0A%0A    @Test%0A    public void call_contentIntentGoesToE() %7B%0A        Notification notification = getNotification();%0A        PendingIntent pendingIntent = notification.contentIntent;%0A        Intent contentIntent = shadowOf(pendingIntent).getSavedIntent();%0A        String nextClasName = contentIntent.getComponent().getClassName();%0A        assertEquals(nextClasName, Notification_E.class.getName());%0A%0A        String value = contentIntent.getStringExtra(%22key%22);%0A        assertEquals(value, %22This is E%22);%0A    %7D%0A%0A%0A
 %0A%7D

add test for notification