Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2011-08-23 00:49:47 +0000
committerSteffen Pingel2011-08-23 00:49:47 +0000
commit88eb0b5a82b31512654a83aa7bd336341c74358a (patch)
tree07995ad18394bc8c1efe93f5447f4b7f450bf529 /org.eclipse.mylyn.tasks.tests
parent322adb87a8732b447c0c271762fe3b861c19c269 (diff)
downloadorg.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.tar.gz
org.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.tar.xz
org.eclipse.mylyn.tasks-88eb0b5a82b31512654a83aa7bd336341c74358a.zip
ASSIGNED - bug 349924: [patch][api] provide extension point for task
activation listeners https://bugs.eclipse.org/bugs/show_bug.cgi?id=349924
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/plugin.xml2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MockTaskActivationListenerExtension.java68
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityManagerTest.java99
3 files changed, 91 insertions, 78 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml
index 28c47f088..345495ff3 100644
--- a/org.eclipse.mylyn.tasks.tests/plugin.xml
+++ b/org.eclipse.mylyn.tasks.tests/plugin.xml
@@ -91,7 +91,7 @@
point="org.eclipse.mylyn.tasks.core.taskActivationListeners">
<listener
id="org.eclipse.mylyn.tasks.tests.listenerTest"
- listenerClass="org.eclipse.mylyn.tasks.tests.MockTaskActivationListenerExtension">
+ class="org.eclipse.mylyn.tasks.tests.TaskActivityManagerTest$MockTaskActivationListenerExtension">
</listener>
</extension>
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MockTaskActivationListenerExtension.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MockTaskActivationListenerExtension.java
deleted file mode 100644
index 854b32a6c..000000000
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MockTaskActivationListenerExtension.java
+++ /dev/null
@@ -1,68 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2011 Manuel Doninger 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:
- * Manuel Doninger - initial API and implementation
- *******************************************************************************/
-
-package org.eclipse.mylyn.tasks.tests;
-
-import org.eclipse.mylyn.tasks.core.ITask;
-import org.eclipse.mylyn.tasks.core.TaskActivationAdapter;
-
-/**
- * A task activation listener that is registered through an extension point.
- *
- * @author Manuel Doninger
- */
-public class MockTaskActivationListenerExtension extends TaskActivationAdapter {
-
- public static MockTaskActivationListenerExtension INSTANCE;
-
- public boolean hasActivated = false;
-
- public boolean hasPreActivated = false;
-
- public boolean hasDeactivated = false;
-
- public boolean hasPreDeactivated = false;
-
- public MockTaskActivationListenerExtension() {
- super();
- INSTANCE = this;
- }
-
- public void reset() {
- hasActivated = false;
- hasPreActivated = false;
-
- hasDeactivated = false;
- hasPreDeactivated = false;
-
- }
-
- @Override
- public void preTaskActivated(ITask task) {
- hasPreActivated = true;
- }
-
- @Override
- public void preTaskDeactivated(ITask task) {
- hasPreDeactivated = true;
- }
-
- @Override
- public void taskActivated(ITask task) {
- hasActivated = true;
- }
-
- @Override
- public void taskDeactivated(ITask task) {
- hasDeactivated = true;
- }
-
-} \ No newline at end of file
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityManagerTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityManagerTest.java
index 3ec02ffc1..9dc0a2d61 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityManagerTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/TaskActivityManagerTest.java
@@ -7,6 +7,7 @@
*
* Contributors:
* Tasktop Technologies - initial API and implementation
+ * Manuel Doninger - fixes for bug 349924
*******************************************************************************/
package org.eclipse.mylyn.tasks.tests;
@@ -34,9 +35,61 @@ import org.eclipse.mylyn.tasks.tests.connector.MockTask;
/**
* @author Shawn Minto
* @author Robert Elves
+ * @author Manuel Doninger
+ * @author Steffen Pingel
*/
public class TaskActivityManagerTest extends TestCase {
+ public static class MockTaskActivationListenerExtension extends TaskActivationAdapter {
+
+ public static MockTaskActivationListenerExtension INSTANCE;
+
+ public static int INSTANCE_COUNT;
+
+ public boolean hasActivated = false;
+
+ public boolean hasPreActivated = false;
+
+ public boolean hasDeactivated = false;
+
+ public boolean hasPreDeactivated = false;
+
+ public MockTaskActivationListenerExtension() {
+ INSTANCE = this;
+ INSTANCE_COUNT++;
+ }
+
+ public void reset() {
+ hasActivated = false;
+ hasPreActivated = false;
+
+ hasDeactivated = false;
+ hasPreDeactivated = false;
+
+ }
+
+ @Override
+ public void preTaskActivated(ITask task) {
+ hasPreActivated = true;
+ }
+
+ @Override
+ public void preTaskDeactivated(ITask task) {
+ hasPreDeactivated = true;
+ }
+
+ @Override
+ public void taskActivated(ITask task) {
+ hasActivated = true;
+ }
+
+ @Override
+ public void taskDeactivated(ITask task) {
+ hasDeactivated = true;
+ }
+
+ }
+
private class MockTaskActivationListener extends TaskActivationAdapter {
private boolean hasActivated = false;
@@ -137,12 +190,7 @@ public class TaskActivityManagerTest extends TestCase {
assertTrue(listener.hasActivated);
assertFalse(listener.hasPreDeactivated);
assertFalse(listener.hasDeactivated);
- assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasPreActivated);
- assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasActivated);
- assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasPreDeactivated);
- assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasDeactivated);
- MockTaskActivationListenerExtension.INSTANCE.reset();
listener.reset();
} finally {
taskActivityManager.deactivateTask(task);
@@ -151,15 +199,48 @@ public class TaskActivityManagerTest extends TestCase {
assertFalse(listener.hasActivated);
assertTrue(listener.hasPreDeactivated);
assertTrue(listener.hasDeactivated);
- assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasPreActivated);
- assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasActivated);
- assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasPreDeactivated);
- assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasDeactivated);
} finally {
taskActivityManager.removeActivationListener(listener);
}
}
+ public void testTaskActivationExtension() {
+ if (MockTaskActivationListenerExtension.INSTANCE != null) {
+ MockTaskActivationListenerExtension.INSTANCE.reset();
+ }
+
+ MockTask task = new MockTask("test:activation");
+ try {
+ taskActivityManager.activateTask(task);
+ assertNotNull("Expected creation of task activation listener instance",
+ MockTaskActivationListenerExtension.INSTANCE);
+ assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasPreActivated);
+ assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasActivated);
+ assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasPreDeactivated);
+ assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasDeactivated);
+
+ MockTaskActivationListenerExtension.INSTANCE.reset();
+ } finally {
+ taskActivityManager.deactivateTask(task);
+ }
+ assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasPreActivated);
+ assertFalse(MockTaskActivationListenerExtension.INSTANCE.hasActivated);
+ assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasPreDeactivated);
+ assertTrue(MockTaskActivationListenerExtension.INSTANCE.hasDeactivated);
+ }
+
+ public void testTaskActivationExtensionInstanceCount() {
+ MockTask task = new MockTask("test:activation");
+ try {
+ taskActivityManager.activateTask(task);
+ assertNotNull("Expected creation of task activation listener instance",
+ MockTaskActivationListenerExtension.INSTANCE);
+ assertEquals(1, MockTaskActivationListenerExtension.INSTANCE_COUNT);
+ } finally {
+ taskActivityManager.deactivateTask(task);
+ }
+ }
+
public void testIsActiveToday() {
AbstractTask task = new LocalTask("1", "task-1");
assertFalse(taskActivityManager.isScheduledForToday(task));

Back to the top