From 7d6bcee9b04dd8eaaf2d44d08ad968877d394d8a Mon Sep 17 00:00:00 2001 From: Tim Su Date: Thu, 19 May 2011 16:47:53 -0700 Subject: [PATCH] Fix unit test with reminders --- astrid/src/com/todoroo/astrid/dao/TaskDao.java | 13 ++++++++----- .../todoroo/astrid/repeats/AdvancedRepeatTests.java | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/astrid/src/com/todoroo/astrid/dao/TaskDao.java b/astrid/src/com/todoroo/astrid/dao/TaskDao.java index 8da00587e..33d278100 100644 --- a/astrid/src/com/todoroo/astrid/dao/TaskDao.java +++ b/astrid/src/com/todoroo/astrid/dao/TaskDao.java @@ -222,15 +222,12 @@ public class TaskDao extends DatabaseDao { /** * Called after the task is saved. This differs from the call in * TaskApiDao in that it runs hooks that need to be run from within - * Astrid. + * Astrid. Order matters here! */ public static void afterSave(Task task, ContentValues values) { - if(TaskApiDao.insignificantChange(values)) + if(values == null) return; - // run global save hooks - TaskApiDao.afterSave(task, values); - if(values.containsKey(Task.COMPLETION_DATE.name) && task.isCompleted()) afterComplete(task, values); else { @@ -242,6 +239,12 @@ public class TaskDao extends DatabaseDao { ReminderService.getInstance().scheduleAlarm(task); } + if(TaskApiDao.insignificantChange(values)) + return; + + // run api save hooks + TaskApiDao.afterSave(task, values); + for(DatabaseUpdateListener listener : taskChangeListeners) { listener.onDatabaseUpdated(); } diff --git a/tests/src/com/todoroo/astrid/repeats/AdvancedRepeatTests.java b/tests/src/com/todoroo/astrid/repeats/AdvancedRepeatTests.java index d489b124c..d9e288adb 100644 --- a/tests/src/com/todoroo/astrid/repeats/AdvancedRepeatTests.java +++ b/tests/src/com/todoroo/astrid/repeats/AdvancedRepeatTests.java @@ -27,9 +27,9 @@ public class AdvancedRepeatTests extends TodorooTestCase { // repeat once => due date should become tomorrow long past = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, new Date(110, 7, 1).getTime()); task.setValue(Task.DUE_DATE, past); - long today = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, DateUtilities.now()); + long tomorrow = task.createDueDate(Task.URGENCY_SPECIFIC_DAY, DateUtilities.now() + DateUtilities.ONE_DAY); long nextDueDate = RepeatTaskCompleteListener.computeNextDueDate(task, rrule.toIcal()); - assertDatesEqual(today, nextDueDate); + assertDatesEqual(tomorrow, nextDueDate); // test specific day & time long pastWithTime = task.createDueDate(Task.URGENCY_SPECIFIC_DAY_TIME, new Date(110, 7, 1, 10, 4).getTime());