Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/plugin.xml7
-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.java9
3 files changed, 84 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml
index 05e2d8021..28c47f088 100644
--- a/org.eclipse.mylyn.tasks.tests/plugin.xml
+++ b/org.eclipse.mylyn.tasks.tests/plugin.xml
@@ -86,6 +86,13 @@
attributeId="version"
connectorKind="trac">
</suppressIncoming>
+ </extension>
+ <extension
+ point="org.eclipse.mylyn.tasks.core.taskActivationListeners">
+ <listener
+ id="org.eclipse.mylyn.tasks.tests.listenerTest"
+ listenerClass="org.eclipse.mylyn.tasks.tests.MockTaskActivationListenerExtension">
+ </listener>
</extension>
</plugin>
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
new file mode 100644
index 000000000..854b32a6c
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/MockTaskActivationListenerExtension.java
@@ -0,0 +1,68 @@
+/*******************************************************************************
+ * 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 de82fcfae..3ec02ffc1 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
@@ -137,7 +137,12 @@ 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);
@@ -146,6 +151,10 @@ 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);
}

Back to the top