public void testDailyAndGreaterFreqs() throws ParseException { task.setValue( Task.DUE_DATE, Task.createDueDate( Task.URGENCY_SPECIFIC_DAY, DateUtilities.now() - DateUtilities.ONE_WEEK)); task.setFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION, true); for (int interval = 1; interval < 7; interval++) { for (Frequency freq : Frequency.values()) { long next = DateUtilities.now(); switch (freq) { case DAILY: next += interval * DateUtilities.ONE_DAY; break; case WEEKLY: next += interval * DateUtilities.ONE_WEEK; break; case MONTHLY: next = DateUtilities.addCalendarMonthsToUnixtime(next, interval); break; case YEARLY: next = DateUtilities.addCalendarMonthsToUnixtime(next, interval * 12); break; default: continue; } buildRRule(interval, freq); nextDueDate = RepeatTaskCompleteListener.computeNextDueDate(task, rrule.toIcal()); assertDateEquals(freq.toString() + "x" + interval, next, nextDueDate); task.setValue(Task.DUE_DATE, nextDueDate); assertFalse(task.hasDueTime()); } } }
public void testSubDailyFreqs() throws ParseException { task.setValue(Task.DUE_DATE, DateUtilities.now() - DateUtilities.ONE_WEEK); task.setFlag(Task.FLAGS, Task.FLAG_REPEAT_AFTER_COMPLETION, true); for (Frequency freq : Frequency.values()) { long interval = -1; switch (freq) { case MINUTELY: interval = DateUtilities.ONE_MINUTE; break; case HOURLY: interval = DateUtilities.ONE_HOUR; break; default: continue; } buildRRule(1, freq); nextDueDate = RepeatTaskCompleteListener.computeNextDueDate(task, rrule.toIcal()); buildRRule(6, freq); nextDueDate = RepeatTaskCompleteListener.computeNextDueDate(task, rrule.toIcal()); assertDateTimeEquals(freq.toString() + "x6", DateUtilities.now() + 6 * interval, nextDueDate); task.setValue(Task.DUE_DATE, nextDueDate); assertTrue(task.hasDueTime()); } }