Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src')
-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
2 files changed, 90 insertions, 77 deletions
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