Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrelves2010-06-25 22:05:48 +0000
committerrelves2010-06-25 22:05:48 +0000
commit40edab6fa0811da9d029a6b36319c77d2dc0b847 (patch)
tree4e7a35250ae9b8a81850f8f5955f0b622fe3ae48 /org.eclipse.mylyn.tasks.tests/src
parentb26ae3ab7977ac2edcab56c5a461eca5adb52835 (diff)
downloadorg.eclipse.mylyn.tasks-40edab6fa0811da9d029a6b36319c77d2dc0b847.tar.gz
org.eclipse.mylyn.tasks-40edab6fa0811da9d029a6b36319c77d2dc0b847.tar.xz
org.eclipse.mylyn.tasks-40edab6fa0811da9d029a6b36319c77d2dc0b847.zip
NEW - bug 316657: scheduled presentation fails to show due tasks for others scheduled for This Week
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316657
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/DateRangeTest.java41
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java126
2 files changed, 159 insertions, 8 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/DateRangeTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/DateRangeTest.java
index e87599513..8be79c550 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/DateRangeTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/DateRangeTest.java
@@ -13,6 +13,7 @@ package org.eclipse.mylyn.tasks.tests;
import java.util.Calendar;
import java.util.Collections;
+import java.util.Date;
import java.util.HashSet;
import java.util.Set;
import java.util.SortedMap;
@@ -75,6 +76,30 @@ public class DateRangeTest extends TestCase {
assertEquals(2, result.size());
}
+ public void testOverScheduled() {
+ SortedMap<DateRange, Set<ITask>> scheduledTasks = Collections.synchronizedSortedMap(new TreeMap<DateRange, Set<ITask>>());
+ DateRange range1 = TaskActivityUtil.getDayOf(new Date(0));
+ Set<ITask> tasks = new HashSet<ITask>();
+ tasks.add(new LocalTask("1", "summaryForLocalTask"));
+ scheduledTasks.put(range1, tasks);
+ assertFalse(scheduledTasks.isEmpty());
+ assertNotNull(scheduledTasks.get(range1));
+
+ Calendar start = TaskActivityUtil.getCalendar();
+ start.setTimeInMillis(0);
+ Calendar end = TaskActivityUtil.getCalendar();
+ TaskActivityUtil.snapStartOfDay(end);
+
+ DateRange startRange = new DateRange(start);
+ Calendar endExclusive = TaskActivityUtil.getCalendar();
+ endExclusive.setTimeInMillis(end.getTimeInMillis() + 1);
+ DateRange endRange = new DateRange(endExclusive);
+
+ SortedMap<DateRange, Set<ITask>> result = scheduledTasks.subMap(startRange, endRange);
+
+ assertEquals(1, result.size());
+ }
+
public void testIsWeekRange() {
TimeZone defaultTimeZone = TimeZone.getDefault();
try {
@@ -85,8 +110,8 @@ public class DateRangeTest extends TestCase {
DateRange range = TaskActivityUtil.getWeekOf(time.getTime());
assertTrue(WeekDateRange.isWeekRange(range.getStartDate(), range.getEndDate()));
range.getStartDate().setTimeInMillis(range.getStartDate().getTimeInMillis() + 1);
- assertTrue("1 ms longer than a week, expected to be within legal interval", WeekDateRange.isWeekRange(
- range.getStartDate(), range.getEndDate()));
+ assertTrue("1 ms longer than a week, expected to be within legal interval",
+ WeekDateRange.isWeekRange(range.getStartDate(), range.getEndDate()));
range = TaskActivityUtil.getDayOf(time.getTime());
assertFalse("only a day", WeekDateRange.isWeekRange(range.getStartDate(), range.getEndDate()));
@@ -123,14 +148,14 @@ public class DateRangeTest extends TestCase {
DateRange range = TaskActivityUtil.getDayOf(time.getTime());
assertTrue(DayDateRange.isDayRange(range.getStartDate(), range.getEndDate()));
range.getStartDate().setTimeInMillis(range.getStartDate().getTimeInMillis() + 1);
- assertTrue("1 ms longer than a day, expected to be within legal interval", DayDateRange.isDayRange(
- range.getStartDate(), range.getEndDate()));
+ assertTrue("1 ms longer than a day, expected to be within legal interval",
+ DayDateRange.isDayRange(range.getStartDate(), range.getEndDate()));
range.getStartDate().setTimeInMillis(range.getStartDate().getTimeInMillis() + HOUR);
- assertFalse("1 hour + 1 ms longer than a day", DayDateRange.isDayRange(range.getStartDate(),
- range.getEndDate()));
+ assertFalse("1 hour + 1 ms longer than a day",
+ DayDateRange.isDayRange(range.getStartDate(), range.getEndDate()));
range.getStartDate().setTimeInMillis(range.getStartDate().getTimeInMillis() - 2 * HOUR - 2);
- assertFalse("1 hour + 1 ms shorter than a day", DayDateRange.isDayRange(range.getStartDate(),
- range.getEndDate()));
+ assertFalse("1 hour + 1 ms shorter than a day",
+ DayDateRange.isDayRange(range.getStartDate(), range.getEndDate()));
range = TaskActivityUtil.getDayOf(time.getTime());
assertTrue("a week", DayDateRange.isDayRange(range.getStartDate(), range.getEndDate()));
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
index c64bc7a5b..b5d0107a8 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ScheduledPresentationTest.java
@@ -12,19 +12,33 @@
package org.eclipse.mylyn.tasks.tests;
import java.util.Calendar;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
import java.util.Set;
import junit.framework.TestCase;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.context.core.ContextCorePlugin;
import org.eclipse.mylyn.internal.context.core.InteractionContextManager;
import org.eclipse.mylyn.internal.tasks.core.AbstractTask;
import org.eclipse.mylyn.internal.tasks.core.DateRange;
+import org.eclipse.mylyn.internal.tasks.core.DayDateRange;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
+import org.eclipse.mylyn.internal.tasks.core.ScheduledTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.TaskActivityUtil;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.views.TaskListInterestFilter;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider;
import org.eclipse.mylyn.monitor.core.InteractionEvent;
+import org.eclipse.mylyn.tasks.core.ITask;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockTask;
/**
* @author Rob Elves
@@ -59,6 +73,118 @@ public class ScheduledPresentationTest extends TestCase {
}
+ public void testScheduledDisplayed() {
+ DateRange lastDay = TaskActivityUtil.getDayOf(TaskActivityUtil.getEndOfCurrentWeek().getTime());
+ AbstractTask task1 = new LocalTask("task 1", "Task 1");
+ TasksUiPlugin.getTaskList().addTask(task1);
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor(task1, lastDay);
+
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND,
+ MockRepositoryConnector.REPOSITORY_URL);
+ repository.setCredentials(AuthenticationType.REPOSITORY, new AuthenticationCredentials("testuser",
+ "testpassword"), false);
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+
+ MockTask mockTask = new MockTask(MockRepositoryConnector.REPOSITORY_URL, "123", "mock task");
+ mockTask.setOwner("anotheruser");
+
+ // Scheduled for THIS WEEK and DUE TODAY and owned by somebody else (bug#316657)
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor(mockTask, TaskActivityUtil.getCurrentWeek());
+ TasksUiPlugin.getTaskActivityManager().setDueDate(mockTask, TaskActivityUtil.getCalendar().getTime());
+ TasksUiPlugin.getTaskList().addTask(mockTask);
+
+ Map<ITask, ScheduledTaskContainer> results = new HashMap<ITask, ScheduledTaskContainer>();
+ results.put(mockTask, null);
+ results.put(task1, null);
+
+ populateResults(results, false);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals("This Week", results.get(mockTask).getSummary());
+ assertNotNull(results.get(task1));
+
+ // Scheduled for NEXT WEEK AND INCOMING
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor(mockTask, TaskActivityUtil.getNextWeek());
+ mockTask.setSynchronizationState(SynchronizationState.INCOMING);
+ results.put(mockTask, null);
+ results.put(task1, null);
+
+ // Should be revealed in Next Week since tasklist NOT in FOCUSED MODE
+ populateResults(results, false);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals("Next Week", results.get(mockTask).getSummary());
+ assertNotNull(results.get(task1));
+
+ results.put(mockTask, null);
+ results.put(task1, null);
+
+ // Should be revealed in INCOMING since tasklist in FOCUSED MODE
+ populateResults(results, true);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals("Incoming", results.get(mockTask).getSummary());
+ assertNotNull(results.get(task1));
+
+ results.put(mockTask, null);
+ results.put(task1, null);
+
+ // Scheduled and Due for a day next week
+ mockTask.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+ TasksUiPlugin.getTaskActivityManager().setDueDate(mockTask,
+ TaskActivityUtil.getNextWeek().getDayOfWeek(3).getStartDate().getTime());
+ populateResults(results, false);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals("Next Week", results.get(mockTask).getSummary());
+
+ results.put(mockTask, null);
+ results.put(task1, null);
+
+ // Overscheduled
+ DayDateRange dayDateRange = TaskActivityUtil.getDayOf(new Date(86400000));
+ TasksUiPlugin.getTaskActivityManager().setScheduledFor(mockTask, dayDateRange);
+ mockTask.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+ results.put(mockTask, null);
+ populateResults(results, false);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertTrue(results.get(mockTask).getSummary().contains("Today"));
+
+ // Scheduled for a specific DAY next week
+ results.put(mockTask, null);
+ TasksUiPlugin.getTaskActivityManager()
+ .setScheduledFor(mockTask, TaskActivityUtil.getNextWeek().getDayOfWeek(3));
+ mockTask.setSynchronizationState(SynchronizationState.SYNCHRONIZED);
+ populateResults(results, false);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals(TaskActivityUtil.getNextWeek().getDayOfWeek(3), results.get(mockTask).getDateRange());
+
+ // Scheduled for a specific DAY next week with INCOMING_NEW
+ results.put(mockTask, null);
+ mockTask.setSynchronizationState(SynchronizationState.INCOMING_NEW);
+ populateResults(results, true);
+ assertNotNull("Task scheduled but not visible in scheduled presentation", results.get(mockTask));
+ assertEquals("Incoming", results.get(mockTask).getSummary());
+ }
+
+ private void populateResults(Map<ITask, ScheduledTaskContainer> results, boolean focused) {
+ TaskListView.getFromActivePerspective().setFocusedMode(focused);
+ TaskScheduleContentProvider provider = new TaskScheduleContentProvider(TaskListView.getFromActivePerspective());
+ Object[] bins = provider.getElements(TaskListView.getFromActivePerspective().getViewSite());
+ TaskListInterestFilter filter = new TaskListInterestFilter();
+ for (Object object : bins) {
+ if (focused) {
+ if (!filter.select(null, object)) {
+ continue;
+ }
+ }
+ for (ITask task : ((ScheduledTaskContainer) object).getChildren()) {
+ if (results.containsKey(task)) {
+ results.put(task, (ScheduledTaskContainer) object);
+ }
+ }
+ }
+ if (focused) {
+ TaskListView.getFromActivePerspective().setFocusedMode(!focused);
+ }
+ }
+
// public void testResetAndRollOver() {
//
// ScheduledTaskContainer pastWeeks = TasksUiPlugin.getTaskActivityManager().getActivityPast();

Back to the top