Force NotificationManager for notification tests

pull/14/head
Tim Su 14 years ago
parent a75438de12
commit 6a6d237a68

@ -67,6 +67,7 @@ public class Notifications extends BroadcastReceiver {
private ExceptionService exceptionService;
public static NotificationManager notificationManager = null;
private static boolean forceNotificationManager = false;
// --- alarm handling
@ -194,7 +195,11 @@ public class Notifications extends BroadcastReceiver {
inAppNotify.putExtra(EXTRAS_TITLE, title);
inAppNotify.putExtra(EXTRAS_TEXT, text);
inAppNotify.putExtra(EXTRAS_RING_TIMES, ringTimes);
context.sendOrderedBroadcast(inAppNotify, AstridApiConstants.PERMISSION_READ);
if(forceNotificationManager)
new ShowNotificationReceiver().onReceive(ContextManager.getContext(), inAppNotify);
else
context.sendOrderedBroadcast(inAppNotify, AstridApiConstants.PERMISSION_READ);
}
/**
@ -408,4 +413,8 @@ public class Notifications extends BroadcastReceiver {
Notifications.notificationManager = notificationManager;
}
}
public static void forceNotificationManager(boolean status) {
forceNotificationManager = status;
}
}

@ -8,7 +8,6 @@ import android.content.Intent;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.NotificationManager;
import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.dao.TaskDao;
@ -27,7 +26,7 @@ public class NotificationTests extends DatabaseTestCase {
@Override
protected void setUp() throws Exception {
super.setUp();
//fail("fix me! i crash a lot.");
Notifications.forceNotificationManager(true);
}
@Override
@ -56,7 +55,6 @@ public class NotificationTests extends DatabaseTestCase {
intent.putExtra(Notifications.ID_KEY, task.getId());
intent.putExtra(Notifications.EXTRAS_TYPE, ReminderService.TYPE_DUE);
new Notifications().onReceive(getContext(), intent);
AndroidUtilities.sleepDeep(500L); // Make sure receive happens
assertTrue(triggered.value);
}

Loading…
Cancel
Save