Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorsminto2005-07-20 19:22:19 -0400
committersminto2005-07-20 19:22:19 -0400
commit6f01a2028ba96990d51973c5614c1c581172a00f (patch)
treeb3832e7328f356f089d71d05879ca983c997683e /org.eclipse.mylyn.tasks.tests/src/org/eclipse
parent4e715109bc79f1edba2624d20cbe84fd00f944b5 (diff)
downloadorg.eclipse.mylyn.tasks-6f01a2028ba96990d51973c5614c1c581172a00f.tar.gz
org.eclipse.mylyn.tasks-6f01a2028ba96990d51973c5614c1c581172a00f.tar.xz
org.eclipse.mylyn.tasks-6f01a2028ba96990d51973c5614c1c581172a00f.zip
kens patch for Bug 104260 merge TaskListManager and TaskList
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src/org/eclipse')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java20
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java12
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java161
3 files changed, 132 insertions, 61 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
index e3d0708ee..44bee8f24 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/bugzilla/tests/BugzillaSearchPluginTest.java
@@ -28,8 +28,8 @@ import org.eclipse.mylar.core.search.IActiveSearchListener;
import org.eclipse.mylar.core.tests.support.WorkspaceSetupHelper;
import org.eclipse.mylar.core.tests.support.search.SearchPluginTestHelper;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
+import org.eclipse.mylar.tasks.TaskListManager;
import org.eclipse.mylar.tasks.internal.TaskCategory;
-import org.eclipse.mylar.tasks.internal.TaskList;
import org.eclipse.mylar.tasks.search.BugzillaMylarSearch;
/*TEST CASES TO HANDLE
@@ -213,10 +213,11 @@ public class BugzillaSearchPluginTest extends TestCase{
String bugPrefix = "Bugzilla-";
- TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
- MylarTasksPlugin.getTaskListManager().setTaskList(t);
+// TaskList t = MylarTasksPlugin.getTaskListManager().getTaskList();
+// MylarTasksPlugin.getTaskListManager().setTaskList(t);
+ TaskListManager manager = MylarTasksPlugin.getTaskListManager();
TaskCategory cat = new TaskCategory("Testing Category");
- t.addCategory(cat);
+ manager.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix +94185, "<bugzilla info>");
cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
@@ -265,7 +266,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 3, c.size());
MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
+ MylarTasksPlugin.getTaskListManager().deleteCategory(cat);
}
//TODO need to test a bug that wraps...should fail since we can only search on a single line
@@ -275,10 +276,11 @@ public class BugzillaSearchPluginTest extends TestCase{
String bugPrefix = "Bugzilla-";
- TaskList t = MylarTasksPlugin.getTaskListManager().createNewTaskList();
- MylarTasksPlugin.getTaskListManager().setTaskList(t);
+// TaskList t = MylarTasksPlugin.getTaskListManager().getTaskList();
+// MylarTasksPlugin.getTaskListManager().setTaskList(t);
+ TaskListManager manager = MylarTasksPlugin.getTaskListManager();
TaskCategory cat = new TaskCategory("Testing Category");
- t.addCategory(cat);
+ manager.addCategory(cat);
BugzillaTask bugTask1 = new BugzillaTask(bugPrefix + 94185, "<bugzilla info>");
cat.addTask(bugTask1);
while(bugTask1.getState() != BugTaskState.FREE){
@@ -323,7 +325,7 @@ public class BugzillaSearchPluginTest extends TestCase{
assertEquals("Results not the right size", 1, c.size());
MylarBugzillaPlugin.getBridge().removeFromLandmarksHash(astNodeType);
- MylarTasksPlugin.getTaskListManager().getTaskList().deleteCategory(cat);
+ MylarTasksPlugin.getTaskListManager().deleteCategory(cat);
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
index 3b37fe171..f301b3465 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListManagerTest.java
@@ -36,17 +36,17 @@ public class TaskListManagerTest extends TestCase {
file.deleteOnExit();
TaskListManager manager = new TaskListManager(file);
- TaskList tlist = manager.getTaskList();
+// TaskList tlist = manager.getTaskList();
Task task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
- tlist.addRootTask(task1);
+ manager.addRootTask(task1);
Task sub1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 1");
task1.addSubTask(sub1);
sub1.setParent(task1);
Task task2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 2");
- tlist.addRootTask(task2);
+ manager.addRootTask(task2);
TaskCategory cat1 = new TaskCategory("Category 1");
- tlist.addCategory(cat1);
+ manager.addCategory(cat1);
Task task3 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 3");
cat1.addTask(task3);
Task sub2 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "sub 2");
@@ -56,7 +56,7 @@ public class TaskListManagerTest extends TestCase {
cat1.addTask(task4);
TaskCategory cat2 = new TaskCategory("Category 2");
- tlist.addCategory(cat2);
+ manager.addCategory(cat2);
Task task5 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 5");
cat2.addTask(task5);
Task task6 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 6");
@@ -66,7 +66,7 @@ public class TaskListManagerTest extends TestCase {
cat2.addTask(report);
BugzillaTask report2 = new BugzillaTask("124", "label 124", true);
- tlist.addRootTask(report2);
+ manager.addRootTask(report2);
assertEquals(manager.getTaskList().getRoots().size(), 5);
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
index 3f9d70a05..d53c5f161 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskListUiTest.java
@@ -11,20 +11,14 @@
package org.eclipse.mylar.tasks.tests;
-import java.io.File;
-
import junit.framework.TestCase;
-import org.eclipse.jface.viewers.IStructuredContentProvider;
-import org.eclipse.jface.viewers.ITreeContentProvider;
import org.eclipse.jface.viewers.TreeViewer;
-import org.eclipse.jface.viewers.Viewer;
import org.eclipse.mylar.tasks.ITask;
import org.eclipse.mylar.tasks.MylarTasksPlugin;
import org.eclipse.mylar.tasks.Task;
import org.eclipse.mylar.tasks.TaskListManager;
import org.eclipse.mylar.tasks.internal.TaskCategory;
-import org.eclipse.mylar.tasks.internal.TaskList;
import org.eclipse.mylar.tasks.internal.TaskPriorityFilter;
import org.eclipse.mylar.tasks.ui.views.TaskListView;
import org.eclipse.swt.widgets.TreeItem;
@@ -36,7 +30,7 @@ import org.eclipse.ui.PartInitException;
*
*/
public class TaskListUiTest extends TestCase {
- private TaskList tlist = null;
+// private TaskList tlist = null;
private TaskCategory cat1 = null;
private Task cat1task1 = null;
private Task cat1task2 = null;
@@ -58,11 +52,12 @@ public class TaskListUiTest extends TestCase {
private final static int CHECK_INCOMPLETE_FILTER = 2;
private final static int CHECK_PRIORITY_FILTER = 3;
- public void setUp() throws PartInitException{
+ public void setUp() throws PartInitException{
+ try {
MylarTasksPlugin.getDefault().getWorkbench().getActiveWorkbenchWindow().getActivePage().showView("org.eclipse.mylar.tasks.ui.views.TaskListView");
- File file = new File("foo" + MylarTasksPlugin.FILE_EXTENSION);
- TaskListManager manager = new TaskListManager(file);
- tlist = manager.createNewTaskList();
+// File file = new File("foo" + MylarTasksPlugin.FILE_EXTENSION);
+ TaskListManager manager = MylarTasksPlugin.getTaskListManager();
+// tlist = manager.getTaskList();
cat1 = new TaskCategory("First Category");
cat1task1 = new Task(MylarTasksPlugin.getTaskListManager().genUniqueTaskId(), "task 1");
@@ -99,7 +94,7 @@ public class TaskListUiTest extends TestCase {
cat1task5.setCategory(cat1);
cat1.addTask(cat1task5);
- tlist.addCategory(cat1);
+ manager.addCategory(cat1);
assertEquals(cat1.getChildren().size(), 5);
cat2 = new TaskCategory("Second Category");
@@ -136,8 +131,11 @@ public class TaskListUiTest extends TestCase {
cat2task5.setCategory(cat2);
cat2.addTask(cat2task5);
- tlist.addCategory(cat2);
+ manager.addCategory(cat2);
manager.saveTaskList();
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
}
public void tearDown() {
@@ -145,16 +143,17 @@ public class TaskListUiTest extends TestCase {
}
public void testUiFilter() {
+ try {
assertNotNull(TaskListView.getDefault());
TreeViewer viewer = TaskListView.getDefault().getViewer();
- viewer.setContentProvider(new ContentProvider());
+ viewer.setContentProvider(TaskListView.getDefault().getContentProvider());
viewer.refresh();
- MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(TaskListView.getDefault().getCompleteFilter());
+ TaskListView.getDefault().addFilter(TaskListView.getDefault().getCompleteFilter());
viewer.refresh();
viewer.expandAll();
TreeItem[] items = viewer.getTree().getItems();
assertTrue(checkFilter(CHECK_COMPLETE_FILTER, items));
- MylarTasksPlugin.getTaskListManager().getTaskList().removeFilter(TaskListView.getDefault().getCompleteFilter());
+ TaskListView.getDefault().removeFilter(TaskListView.getDefault().getCompleteFilter());
// MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(TaskListView.getDefault().getInCompleteFilter());
@@ -168,13 +167,16 @@ public class TaskListUiTest extends TestCase {
TaskPriorityFilter filter = (TaskPriorityFilter)TaskListView.getDefault().getPriorityFilter();
filter.displayPrioritiesAbove("P2");
- MylarTasksPlugin.getTaskListManager().getTaskList().addFilter(filter);
+ TaskListView.getDefault().addFilter(filter);
viewer.refresh();
viewer.expandAll();
items = viewer.getTree().getItems();
// check priority tasks
- assertTrue(checkFilter(CHECK_PRIORITY_FILTER, items));
+ assertTrue(checkFilter(CHECK_PRIORITY_FILTER, items));
+ } catch(Exception e) {
+ e.printStackTrace();
+ }
}
public boolean checkFilter(int type, TreeItem[] items) {
@@ -187,7 +189,7 @@ public class TaskListUiTest extends TestCase {
}
public boolean checkCompleteIncompleteFilter(TreeItem[] items, boolean checkComplete) {
- assertTrue(items.length == 2);
+ assertEquals(2, items.length);
int count = 0;
for (int i = 0; i < items.length; i++) {
assertTrue(items[i].getData() instanceof TaskCategory);
@@ -230,31 +232,98 @@ public class TaskListUiTest extends TestCase {
return true;
}
- class ContentProvider implements IStructuredContentProvider, ITreeContentProvider {
- public void inputChanged(Viewer v, Object oldInput, Object newInput) {
- // don't care if the input changes
- }
- public void dispose() {
- // don't care if we are disposed
- }
- public Object[] getElements(Object parent) {
- return tlist.getRoots().toArray();
- }
- public Object getParent(Object child) {
- if (child instanceof TaskCategory) {
- return ((Task)child).getCategory();
- }
- return null;
- }
- public Object [] getChildren(Object parent) {
- return MylarTasksPlugin.getTaskListManager().getTaskList().getFilteredChildrenFor(parent).toArray();
- }
- public boolean hasChildren(Object parent) {
- if (parent instanceof TaskCategory) {
- TaskCategory cat = (TaskCategory)parent;
- return cat.getChildren() != null && cat.getChildren().size() > 0;
- }
- return false;
- }
- }
+// class ContentProvider implements IStructuredContentProvider, ITreeContentProvider {
+// public void inputChanged(Viewer v, Object oldInput, Object newInput) {
+// // don't care if the input changes
+// }
+// public void dispose() {
+// // don't care if we are disposed
+// }
+// public Object[] getElements(Object parent) {
+// return applyFilter(MylarTasksPlugin.getTaskListManager().getTaskList().getRoots()).toArray();
+// }
+// public Object getParent(Object child) {
+// if (child instanceof ITask) {
+// if (((ITask)child).getParent() != null) {
+// return ((ITask)child).getParent();
+// } else {
+// return ((ITask)child).getCategory();
+// }
+//
+// }
+// return null;
+// }
+// public Object [] getChildren(Object parent) {
+// return getFilteredChildrenFor(parent).toArray();
+// }
+// public boolean hasChildren(Object parent) {
+// if (parent instanceof AbstractCategory) {
+// AbstractCategory cat = (AbstractCategory)parent;
+// return cat.getChildren() != null && cat.getChildren().size() > 0;
+// } else if (parent instanceof Task) {
+// Task t = (Task) parent;
+// return t.getChildren() != null && t.getChildren().size() > 0;
+// }
+// return false;
+// }
+// private List<Object> applyFilter(List<Object> list) {
+// List<Object> filteredRoots = new ArrayList<Object>();
+// for (int i = 0; i < list.size(); i++) {
+// if (list.get(i) instanceof ITask) {
+// if (!filter(list.get(i))) {
+// filteredRoots.add(list.get(i));
+// }
+// } else if (list.get(i) instanceof AbstractCategory) {
+// if (selectCategory((AbstractCategory)list.get(i))) {
+// filteredRoots.add(list.get(i));
+// }
+// }
+// }
+// return filteredRoots;
+// }
+//
+// private boolean selectCategory(AbstractCategory cat) {
+// List<? extends ITaskListElement> list = cat.getChildren();
+// if (list.size() == 0) {
+// return true;
+// }
+// for (int i = 0; i < list.size(); i++) {
+// if (!filter(list.get(i))) {
+// return true;
+// }
+// }
+// return false;
+// }
+//
+// private List<Object> getFilteredChildrenFor(Object parent) {
+// List<Object> children = new ArrayList<Object>();
+// if (parent instanceof AbstractCategory) {
+// List<? extends ITaskListElement> list = ((AbstractCategory)parent).getChildren();
+// for (int i = 0; i < list.size(); i++) {
+// if (!filter(list.get(i))) {
+// children.add(list.get(i));
+// }
+// }
+// return children;
+// } else if (parent instanceof Task) {
+// List<ITask> subTasks = ((Task)parent).getChildren();
+// for (ITask t : subTasks) {
+// if (!filter(t)) {
+// children.add(t);
+// }
+// }
+// return children;
+// }
+// return new ArrayList<Object>();
+// }
+//
+// private boolean filter(Object obj){
+// for (ITaskFilter filter : filters) {
+// if (!filter.select(obj)) {
+// return true;
+// }
+// }
+// return false;
+// }
+// }
}

Back to the top