Home | History | Annotate | Download | only in shadows
      1 package com.xtremelabs.robolectric.shadows;
      2 
      3 import android.app.Notification;
      4 import android.app.PendingIntent;
      5 import android.content.Context;
      6 import com.xtremelabs.robolectric.internal.Implementation;
      7 import com.xtremelabs.robolectric.internal.Implements;
      8 import com.xtremelabs.robolectric.internal.RealObject;
      9 
     10 @SuppressWarnings({"UnusedDeclaration"})
     11 @Implements(Notification.class)
     12 public class ShadowNotification {
     13 
     14     public Notification getRealNotification() {
     15         return realNotification;
     16     }
     17 
     18     @RealObject
     19     Notification realNotification;
     20 
     21     private LatestEventInfo latestEventInfo;
     22 
     23     public void __constructor__(int icon, CharSequence tickerText, long when) {
     24         realNotification.icon = icon;
     25         realNotification.tickerText = tickerText;
     26         realNotification.when = when;
     27     }
     28 
     29     @Implementation
     30     public void setLatestEventInfo(Context context, CharSequence contentTitle,
     31                                    CharSequence contentText, PendingIntent contentIntent) {
     32         latestEventInfo = new LatestEventInfo(contentTitle, contentText, contentIntent);
     33         realNotification.contentIntent = contentIntent;
     34     }
     35 
     36     public LatestEventInfo getLatestEventInfo() {
     37         return latestEventInfo;
     38     }
     39 
     40     public static class LatestEventInfo {
     41         private final CharSequence contentTitle;
     42         private final CharSequence contentText;
     43         private final PendingIntent contentIntent;
     44 
     45         private LatestEventInfo(CharSequence contentTitle, CharSequence contentText, PendingIntent contentIntent) {
     46             this.contentTitle = contentTitle;
     47             this.contentText = contentText;
     48             this.contentIntent = contentIntent;
     49         }
     50 
     51         public CharSequence getContentTitle() {
     52             return contentTitle;
     53         }
     54 
     55         public CharSequence getContentText() {
     56             return contentText;
     57         }
     58 
     59         public PendingIntent getContentIntent() {
     60             return contentIntent;
     61         }
     62     }
     63 }
     64