You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
tasks/tests/plugin-src/com/todoroo/astrid/reminders/AssertiveNotificationManage...

47 lines
1.1 KiB
Java

package com.todoroo.astrid.reminders;
import android.app.Notification;
import android.content.Context;
import com.todoroo.andlib.service.NotificationManager.AndroidNotificationManager;
/**
* Notification manager that provides notifications and adds an
* extra method for verification.
*
* @author timsu
*
*/
public class AssertiveNotificationManager extends AndroidNotificationManager {
Notification notification = null;
public AssertiveNotificationManager(Context context) {
super(context);
}
@Override
public void notify(int id, Notification notification) {
super.notify(id, notification);
this.notification = notification;
}
public void assertNotified() {
if(notification == null)
throw new AssertionError("Notification was not triggered");
}
public void assertNotNotified() {
if(notification != null)
throw new AssertionError("Notification was triggered");
}
public Notification getNotification() {
return notification;
}
public void clear() {
notification = null;
}
}