Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2012-05-29 20:50:02 +0000
committerSam Davis2012-06-04 18:27:32 +0000
commit19ad3705b613a9238847eea385fda36cc3474a41 (patch)
tree1f5356705fc28ad6fdf7fbc3d6bb1404e57adaef /org.eclipse.mylyn.tasks.tests
parent87a55743c4752c4c89690f8b6e7b41b826ae6dbf (diff)
downloadorg.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.tar.gz
org.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.tar.xz
org.eclipse.mylyn.tasks-19ad3705b613a9238847eea385fda36cc3474a41.zip
NEW - bug 338013: [patch] mark as read on incoming folder ignores
working sets https://bugs.eclipse.org/bugs/show_bug.cgi?id=338013 Change-Id: Ib06b4fa49989634f045d1b9a66c31e3a5d79e428
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java98
1 files changed, 98 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
index 8a7e9d6f4..fb9124a3f 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/MarkTaskHandlerTest.java
@@ -11,22 +11,39 @@
package org.eclipse.mylyn.tasks.tests.ui;
+import java.util.ArrayList;
+import java.util.Arrays;
import java.util.HashSet;
+import java.util.List;
import junit.framework.TestCase;
import org.eclipse.core.commands.NotEnabledException;
+import org.eclipse.core.runtime.IAdaptable;
+import org.eclipse.jface.viewers.IContentProvider;
+import org.eclipse.jface.viewers.ITreeContentProvider;
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.mylyn.internal.tasks.core.AbstractTaskContainer;
import org.eclipse.mylyn.internal.tasks.core.LocalTask;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.ScheduledPresentation;
import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.commands.MarkTaskHandler.MarkTaskCompleteHandler;
+import org.eclipse.mylyn.internal.tasks.ui.commands.MarkTaskHandler.MarkTaskReadHandler;
+import org.eclipse.mylyn.internal.tasks.ui.views.AbstractTaskListPresentation;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskScheduleContentProvider.Incoming;
import org.eclipse.mylyn.internal.tasks.ui.workingsets.TaskWorkingSetUpdater;
+import org.eclipse.mylyn.tasks.core.ITask.SynchronizationState;
import org.eclipse.mylyn.tasks.core.TaskRepository;
import org.eclipse.mylyn.tasks.tests.TaskTestUtil;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.ui.IWorkingSet;
+import org.eclipse.ui.IWorkingSetManager;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.handlers.IHandlerService;
+import org.eclipse.ui.internal.Workbench;
/**
* @author Steffen Pingel
@@ -35,6 +52,10 @@ public class MarkTaskHandlerTest extends TestCase {
private IHandlerService handlerService;
+ private IWorkingSet workingSet;
+
+ private IWorkingSetManager workingSetManager;
+
@Override
protected void setUp() throws Exception {
TaskTestUtil.resetTaskListAndRepositories();
@@ -47,11 +68,16 @@ public class MarkTaskHandlerTest extends TestCase {
// TODO figure out which test leaves a filter enabled
TaskWorkingSetUpdater.applyWorkingSetsToAllWindows(new HashSet<IWorkingSet>(0));
TaskTestUtil.openTasksViewInActivePerspective().clearFilters();
+ workingSetManager = Workbench.getInstance().getWorkingSetManager();
}
@Override
protected void tearDown() throws Exception {
TaskTestUtil.resetTaskListAndRepositories();
+ if (workingSet != null) {
+ workingSetManager.removeWorkingSet(workingSet);
+ workingSet = null;
+ }
}
public void testMarkTaskCompleted() throws Exception {
@@ -87,4 +113,76 @@ public class MarkTaskHandlerTest extends TestCase {
}
}
+ public void testMarkWorkingSetIncomingRead() throws Exception {
+ workingSet = createAndSelectWorkingSet();
+ Incoming incoming = setScheduledPresentationAndSelectIncoming();
+ TaskTask taskInWorkingSet = createIncomingTask("1", incoming, workingSet);
+ TaskTask taskNotInWorkingSet = createIncomingTask("2", incoming, null);
+ assertTrue(workingSetContainsTask(taskInWorkingSet));
+ assertFalse(workingSetContainsTask(taskNotInWorkingSet));
+
+ assertTrue(taskInWorkingSet.getSynchronizationState().isIncoming());
+ assertTrue(taskNotInWorkingSet.getSynchronizationState().isIncoming());
+ handlerService.executeCommand(MarkTaskReadHandler.ID_COMMAND, null);
+ assertFalse(taskInWorkingSet.getSynchronizationState().isIncoming());
+ assertTrue(taskNotInWorkingSet.getSynchronizationState().isIncoming());
+ }
+
+ protected boolean workingSetContainsTask(TaskTask taskInWorkingSet) {
+ List<IAdaptable> elements = Arrays.asList(workingSet.getElements());
+ for (AbstractTaskContainer parent : taskInWorkingSet.getParentContainers()) {
+ if (elements.contains(parent)) {
+ return true;
+ }
+ }
+ return false;
+ }
+
+ protected Incoming setScheduledPresentationAndSelectIncoming() throws Exception {
+ TaskListView taskListView = TaskTestUtil.openTasksViewInActivePerspective();
+ for (AbstractTaskListPresentation presentation : TaskListView.getPresentations()) {
+ if (presentation.getId().equals(ScheduledPresentation.ID)) {
+ taskListView.applyPresentation(presentation);
+ break;
+ }
+ }
+ taskListView.setFocusedMode(true);
+ taskListView.refresh();
+ assertTrue(taskListView.getCurrentPresentation().getId().equals(ScheduledPresentation.ID));
+ // select incoming container
+ IContentProvider contentProvider = taskListView.getViewer().getContentProvider();
+ assertTrue(contentProvider instanceof ITreeContentProvider);
+ for (Object element : ((ITreeContentProvider) contentProvider).getElements(taskListView.getViewSite())) {
+ if (element instanceof Incoming) {
+ taskListView.getViewer().setSelection(new StructuredSelection(element), true);
+ }
+ }
+ assertEquals(taskListView.getSelectedTaskContainers().size(), 1);
+ assertTrue(taskListView.getSelectedTaskContainers().get(0) instanceof Incoming);
+ return (Incoming) taskListView.getSelectedTaskContainers().get(0);
+ }
+
+ protected TaskTask createIncomingTask(String id, Incoming incoming, IWorkingSet workingSet) throws Exception {
+ RepositoryQuery query = TaskTestUtil.createMockQuery("query." + id);
+ TasksUiPlugin.getTaskList().addQuery(query);
+ if (workingSet != null) {
+ workingSet.setElements(new IAdaptable[] { query });
+ }
+ TaskTask task = TaskTestUtil.createMockTask(id);
+ TasksUiPlugin.getTaskList().addTask(task, query);
+ task.setSynchronizationState(SynchronizationState.INCOMING);
+ assertTrue(incoming.getChildren().contains(task));
+ return task;
+ }
+
+ protected IWorkingSet createAndSelectWorkingSet() {
+ IWorkingSet workingSet = workingSetManager.createWorkingSet("Task Working Set", new IAdaptable[] {});
+ workingSet.setId(TaskWorkingSetUpdater.ID_TASK_WORKING_SET);
+ ArrayList<IWorkingSet> list = new ArrayList<IWorkingSet>();
+ list.add(workingSet);
+ TaskWorkingSetUpdater.applyWorkingSetsToAllWindows(list);
+ assertTrue(TaskWorkingSetUpdater.isWorkingSetEnabled(workingSet));
+ return workingSet;
+ }
+
}

Back to the top