Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2010-10-25 16:56:36 +0000
committerspingel2010-10-25 16:56:36 +0000
commit26d5f8f07aeebcb04cd1e2274d6a44b8cd750416 (patch)
tree05d1924de6a2e35a552033b6a329d426ad866816 /org.eclipse.mylyn.tasks.tests/src
parent02b331043d5a8e395c4ca6836ff7fcde484fd338 (diff)
downloadorg.eclipse.mylyn.tasks-26d5f8f07aeebcb04cd1e2274d6a44b8cd750416.tar.gz
org.eclipse.mylyn.tasks-26d5f8f07aeebcb04cd1e2274d6a44b8cd750416.tar.xz
org.eclipse.mylyn.tasks-26d5f8f07aeebcb04cd1e2274d6a44b8cd750416.zip
NEW - bug 310092: active task editor does not correspond to the task list selection
https://bugs.eclipse.org/bugs/show_bug.cgi?id=310092
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListViewTest.java113
2 files changed, 115 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index 537190d3c..e66fe0710 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -24,6 +24,7 @@ import org.eclipse.mylyn.tasks.tests.ui.TaskAttachmentPropertyTesterTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskAttributeDiffTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskHyperlinkDetectorTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskListSynchronizationSchedulerTest;
+import org.eclipse.mylyn.tasks.tests.ui.TaskListViewTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskRelationHyperlinkDetectorTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.EditorUtilTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.PlanningPartTest;
@@ -106,6 +107,7 @@ public class AllTasksTests {
suite.addTestSuite(TaskAttributeDiffTest.class);
suite.addTestSuite(ServiceMessageManagerTest.class);
suite.addTestSuite(TaskMigratorTest.class);
+ suite.addTestSuite(TaskListViewTest.class);
// XXX long running tests, put back?
//suite.addTestSuite(QueryExportImportTest.class);
//suite.addTestSuite(BackgroundSaveTest.class);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListViewTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListViewTest.java
new file mode 100644
index 000000000..f2015a609
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListViewTest.java
@@ -0,0 +1,113 @@
+/*******************************************************************************
+ * Copyright (c) 2010 Tasktop Technologies and others.
+ * All rights reserved. This program and the accompanying materials
+ * are made available under the terms of the Eclipse Public License v1.0
+ * which accompanies this distribution, and is available at
+ * http://www.eclipse.org/legal/epl-v10.html
+ *
+ * Contributors:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.viewers.StructuredSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.mylyn.internal.provisional.commons.ui.WorkbenchUtil;
+import org.eclipse.mylyn.internal.tasks.core.RepositoryQuery;
+import org.eclipse.mylyn.internal.tasks.core.TaskCategory;
+import org.eclipse.mylyn.internal.tasks.core.TaskList;
+import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.views.TaskListView;
+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.mylyn.tasks.ui.ITasksUiConstants;
+
+/**
+ * @author Steffen Pingel
+ */
+public class TaskListViewTest extends TestCase {
+
+ private TaskRepository repository;
+
+ @Override
+ protected void setUp() throws Exception {
+ TaskTestUtil.resetTaskListAndRepositories();
+ repository = TaskTestUtil.createMockRepository();
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ TaskTestUtil.resetTaskListAndRepositories();
+ }
+
+ public void testSelectedAndFocusTaskMultiple() {
+ TaskList taskList = TasksUiPlugin.getTaskList();
+ TaskCategory category1 = new TaskCategory(taskList.getUniqueHandleIdentifier());
+ taskList.addCategory(category1);
+
+ TaskTask task1 = TaskTestUtil.createMockTask("task1");
+ TaskTask task2 = TaskTestUtil.createMockTask("task2");
+
+ taskList.addTask(task1, category1);
+ taskList.addTask(task2, category1);
+
+ TaskListView view = (TaskListView) WorkbenchUtil.showViewInActiveWindow(ITasksUiConstants.ID_VIEW_TASKS);
+ view.refresh();
+
+ TreeSelection selection = new TreeSelection(new TreePath(new Object[] { category1, task1 }));
+ // select multiple
+ view.getViewer().setSelection(new StructuredSelection(new Object[] { task1, task2 }));
+ view.selectedAndFocusTask(task1);
+ // make sure only a single task is selected
+ assertEquals(toString(selection), toString(((TreeSelection) view.getViewer().getSelection())));
+ }
+
+ public void testSelectedAndFocusTaskRestore() {
+ TaskList taskList = TasksUiPlugin.getTaskList();
+ TaskCategory category1 = new TaskCategory(taskList.getUniqueHandleIdentifier());
+ taskList.addCategory(category1);
+ // create a query since tasks can only be in one category
+ RepositoryQuery category2 = new RepositoryQuery(MockRepositoryConnector.CONNECTOR_KIND,
+ taskList.getUniqueHandleIdentifier());
+ taskList.addQuery(category2);
+
+ TaskTask task1 = TaskTestUtil.createMockTask("task1");
+
+ taskList.addTask(task1, category1);
+ taskList.addTask(task1, category2);
+
+ TaskListView view = (TaskListView) WorkbenchUtil.showViewInActiveWindow(ITasksUiConstants.ID_VIEW_TASKS);
+ view.refresh();
+
+ TreeSelection selection = new TreeSelection(new TreePath(new Object[] { category1, task1 }));
+ view.getViewer().setSelection(selection);
+ view.selectedAndFocusTask(task1);
+ assertEquals(toString(selection), toString(((TreeSelection) view.getViewer().getSelection())));
+
+ // select different path and restore original path
+ view.getViewer().setSelection(new TreeSelection(new TreePath(new Object[] { category2, task1 })));
+ view.selectedAndFocusTask(task1);
+ assertEquals(selection, view.getViewer().getSelection());
+ }
+
+ private String toString(TreeSelection s1) {
+ StringBuilder sb = new StringBuilder();
+ for (TreePath path : s1.getPaths()) {
+ sb.append("[");
+ for (int i = 0; i < path.getSegmentCount(); i++) {
+ sb.append(path.getSegment(i));
+ sb.append(", ");
+ }
+ sb.setLength(sb.length() - 2);
+ sb.append("]");
+ }
+ return sb.toString();
+ }
+
+}

Back to the top