From 6a6d237a68e4a192c5122b970e14cdb6391e5b8c Mon Sep 17 00:00:00 2001 From: Tim Su Date: Sun, 19 Feb 2012 02:17:05 -0800 Subject: [PATCH] Force NotificationManager for notification tests --- .../com/todoroo/astrid/reminders/Notifications.java | 13 +++++++++++-- .../todoroo/astrid/reminders/NotificationTests.java | 4 +--- 2 files changed, 12 insertions(+), 5 deletions(-) diff --git a/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java b/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java index e4bcdc8bd..8f605fb2a 100644 --- a/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java +++ b/astrid/plugin-src/com/todoroo/astrid/reminders/Notifications.java @@ -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; } -} \ No newline at end of file + public static void forceNotificationManager(boolean status) { + forceNotificationManager = status; + } + +} diff --git a/tests/src/com/todoroo/astrid/reminders/NotificationTests.java b/tests/src/com/todoroo/astrid/reminders/NotificationTests.java index 3313b0353..a343dd1fa 100644 --- a/tests/src/com/todoroo/astrid/reminders/NotificationTests.java +++ b/tests/src/com/todoroo/astrid/reminders/NotificationTests.java @@ -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); }