Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSam Davis2015-08-25 22:49:26 +0000
committerSam Davis2015-08-26 16:53:08 +0000
commitd7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2 (patch)
tree12c8688b6f8cb9ebe51fffee2dd3a657a2a6043b /org.eclipse.mylyn.tasks.tests
parent5528c60382bc995bcf112133696b4bdaf215f991 (diff)
downloadorg.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.tar.gz
org.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.tar.xz
org.eclipse.mylyn.tasks-d7d046ca38d3dfbeef93e4f7a0939d0ea436f5c2.zip
475540: enable plugins to display messages using the task list message
service Change-Id: I524a266b0ea4770a07511b543bcd4f5643337890 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=475540
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF4
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java82
2 files changed, 85 insertions, 1 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
index b523111a2..5bc10a930 100644
--- a/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.mylyn.tasks.tests/META-INF/MANIFEST.MF
@@ -32,7 +32,9 @@ Require-Bundle: org.junit;bundle-version="4.8.2",
org.eclipse.mylyn.tests.util,
org.eclipse.mylyn.commons.repositories.core,
org.eclipse.core.runtime.compatibility.auth;resolution:=optional,
- com.google.guava;bundle-version="15.0.0"
+ com.google.guava;bundle-version="15.0.0",
+ org.eclipse.mylyn.commons.notifications.feed,
+ org.eclipse.mylyn.commons.notifications.core
Export-Package: org.eclipse.mylyn.tasks.tests;x-internal:=true,
org.eclipse.mylyn.tasks.tests.bugs;x-internal:=true,
org.eclipse.mylyn.tasks.tests.connector;x-friends:="org.eclipse.mylyn.tasks.ui.tests",
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
index b8edda030..95501b24e 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/TaskListServiceMessageControlTest.java
@@ -13,13 +13,41 @@ package org.eclipse.mylyn.tasks.tests.ui;
import junit.framework.TestCase;
+import org.eclipse.jface.dialogs.Dialog;
+import org.eclipse.mylyn.commons.notifications.feed.ServiceMessageEvent;
+import org.eclipse.mylyn.commons.notifications.feed.ServiceMessageEvent.Kind;
+import org.eclipse.mylyn.commons.workbench.WorkbenchUtil;
+import org.eclipse.mylyn.internal.commons.notifications.feed.ServiceMessage;
+import org.eclipse.mylyn.internal.tasks.ui.ITasksUiPreferenceConstants;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.internal.tasks.ui.notifications.TaskListServiceMessageControl;
+import org.eclipse.swt.widgets.Composite;
+
+import com.google.common.collect.ImmutableList;
/**
* @author Steffen Pingel
*/
public class TaskListServiceMessageControlTest extends TestCase {
+ private final class TestTaskListServiceMessageControl extends TaskListServiceMessageControl {
+ private TestTaskListServiceMessageControl(Composite parent) {
+ super(parent);
+ }
+
+ @Override
+ protected void closeMessage() {
+ super.closeMessage();
+ }
+ }
+
+ @Override
+ protected void setUp() throws Exception {
+ TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .setValue(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID, "");
+ }
+
public void testGetAction() {
assertEquals("abc", TaskListServiceMessageControl.getAction("ABC"));
assertEquals("abc", TaskListServiceMessageControl.getAction("abc"));
@@ -28,4 +56,58 @@ public class TaskListServiceMessageControlTest extends TestCase {
assertEquals(null, TaskListServiceMessageControl.getAction("http://eclipse.org?foo=bar&action=defg"));
}
+ public void testCloseMessageWithNoId() {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ control.setMessage(new ServiceMessage("123"));
+ control.closeMessage();
+ assertEquals("", getLastMessageId());
+ }
+
+ public void testCloseMessageWithId() {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ ServiceMessage message = new ServiceMessage("123");
+ message.setId("300");
+ control.setMessage(message);
+ control.closeMessage();
+ assertEquals("300", getLastMessageId());
+ }
+
+ public void testHandleEvent() throws Exception {
+ TestTaskListServiceMessageControl control = new TestTaskListServiceMessageControl(WorkbenchUtil.getShell());
+ handleMessage(control, "123");
+ control.closeMessage();
+ assertEquals("123", getLastMessageId());
+
+ handleMessage(control, "100");
+ control.closeMessage();
+ assertEquals("123", getLastMessageId());
+
+ handleMessage(control, "200");
+ control.closeMessage();
+ assertEquals("200", getLastMessageId());
+
+ handleMessage(control, "org.eclipse.mylyn.reset.1");
+ control.closeMessage();
+ assertEquals("", getLastMessageId());
+
+ handleMessage(control, "hello");
+ control.closeMessage();
+ assertEquals("hello", getLastMessageId());
+ }
+
+ private String getLastMessageId() {
+ return TasksUiPlugin.getDefault()
+ .getPreferenceStore()
+ .getString(ITasksUiPreferenceConstants.LAST_SERVICE_MESSAGE_ID);
+ }
+
+ private void handleMessage(TestTaskListServiceMessageControl control, String id) {
+ ServiceMessage message = new ServiceMessage("123");
+ message.setTitle("Title");
+ message.setDescription("Description");
+ message.setImage(Dialog.DLG_IMG_HELP);
+ message.setId(id);
+ control.handleEvent(new ServiceMessageEvent(TasksUiPlugin.getDefault().getServiceMessageManager(),
+ Kind.MESSAGE_UPDATE, ImmutableList.of(message)));
+ }
}

Back to the top