Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLeo Dos Santos2013-12-16 16:55:32 -0500
committerGerrit Code Review @ Eclipse.org2014-01-21 16:11:33 -0500
commit2ee34447ece6defdc170aea9168145894465dce7 (patch)
treea514aa0b87b1763d6219cb7b734c4631053c4f03 /org.eclipse.mylyn.tasks.tests
parentf6291e4a1d8816da3f33e9241294dd0102b74e28 (diff)
downloadorg.eclipse.mylyn.tasks-2ee34447ece6defdc170aea9168145894465dce7.tar.gz
org.eclipse.mylyn.tasks-2ee34447ece6defdc170aea9168145894465dce7.tar.xz
org.eclipse.mylyn.tasks-2ee34447ece6defdc170aea9168145894465dce7.zip
424188: Task attributes that set META_ATTRIBUTE_MEDIA_TYPE should be
displayed with the correct markup viewer when available. Change-Id: Iad8f6f1070d6572702c9e5f71aaebcb8c91e776d Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=424188 Signed-off-by: Leo Dos Santos <leo.dos.santos@tasktop.com>
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/plugin.xml13
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java2
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockTextileEditorExtension.java44
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockWikiEditorExtension.java43
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskEditorExtensionsTest.java95
5 files changed, 197 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml
index a2c0b0b6c..8618babff 100644
--- a/org.eclipse.mylyn.tasks.tests/plugin.xml
+++ b/org.eclipse.mylyn.tasks.tests/plugin.xml
@@ -226,5 +226,18 @@
</adapter>
</factory>
</extension>
+ <extension
+ point="org.eclipse.mylyn.tasks.ui.taskEditorExtensions">
+ <taskEditorExtension
+ class="org.eclipse.mylyn.tasks.tests.ui.editor.MockWikiEditorExtension"
+ id="org.eclipse.mylyn.tasks.tests.editor.mock.wiki"
+ name="MockWiki">
+ </taskEditorExtension>
+ <taskEditorExtension
+ class="org.eclipse.mylyn.tasks.tests.ui.editor.MockTextileEditorExtension"
+ id="org.eclipse.mylyn.tasks.tests.editor.mock.textile"
+ name="MockTextile">
+ </taskEditorExtension>
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
index 88730ef7f..176d26f7f 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/AllTasksTests.java
@@ -43,6 +43,7 @@ import org.eclipse.mylyn.tasks.tests.ui.TaskListSynchronizationSchedulerTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskListViewTest;
import org.eclipse.mylyn.tasks.tests.ui.TaskRelationHyperlinkDetectorTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.AttachmentTableLabelProviderTest;
+import org.eclipse.mylyn.tasks.tests.ui.editor.TaskEditorExtensionsTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.EditorUtilTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.PlanningPartTest;
import org.eclipse.mylyn.tasks.tests.ui.editor.RegionComparatorTest;
@@ -162,6 +163,7 @@ public class AllTasksTests {
suite.addTestSuite(RepositoryConnectorContributorTest.class);
suite.addTestSuite(TaskInitializationDataTest.class);
suite.addTestSuite(TaskDataDiffTest.class);
+ suite.addTestSuite(TaskEditorExtensionsTest.class);
}
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockTextileEditorExtension.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockTextileEditorExtension.java
new file mode 100644
index 000000000..268ab0fcc
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockTextileEditorExtension.java
@@ -0,0 +1,44 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui.editor;
+
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Leo Dos Santos
+ */
+public class MockTextileEditorExtension extends AbstractTaskEditorExtension {
+
+ @Deprecated
+ @Override
+ public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style) {
+ // ignore
+ return null;
+ }
+
+ @Deprecated
+ @Override
+ public SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style) {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public String getEditorContextId() {
+ // ignore
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockWikiEditorExtension.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockWikiEditorExtension.java
new file mode 100644
index 000000000..89ab58d35
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/MockWikiEditorExtension.java
@@ -0,0 +1,43 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui.editor;
+
+import org.eclipse.jface.text.source.SourceViewer;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension;
+import org.eclipse.swt.widgets.Composite;
+
+/**
+ * @author Leo Dos Santos
+ */
+public class MockWikiEditorExtension extends AbstractTaskEditorExtension {
+
+ @Deprecated
+ @Override
+ public SourceViewer createViewer(TaskRepository taskRepository, Composite parent, int style) {
+ return null;
+ }
+
+ @Deprecated
+ @Override
+ public SourceViewer createEditor(TaskRepository taskRepository, Composite parent, int style) {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public String getEditorContextId() {
+ // ignore
+ return null;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskEditorExtensionsTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskEditorExtensionsTest.java
new file mode 100644
index 000000000..f752f4140
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/editor/TaskEditorExtensionsTest.java
@@ -0,0 +1,95 @@
+/*******************************************************************************
+ * Copyright (c) 2013 Tasktop Technologies 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:
+ * Tasktop Technologies - initial API and implementation
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests.ui.editor;
+
+import junit.framework.TestCase;
+
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.internal.tasks.ui.editors.TaskEditorExtensions;
+import org.eclipse.mylyn.tasks.core.TaskRepository;
+import org.eclipse.mylyn.tasks.core.data.TaskAttribute;
+import org.eclipse.mylyn.tasks.core.data.TaskAttributeMapper;
+import org.eclipse.mylyn.tasks.core.data.TaskData;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.ui.editors.AbstractTaskEditorExtension;
+
+/**
+ * @author Leo Dos Santos
+ */
+public class TaskEditorExtensionsTest extends TestCase {
+
+ private static final String ID_TEXTILE_EXTENSION = "org.eclipse.mylyn.tasks.tests.editor.mock.textile";
+
+ private TaskRepository repository;
+
+ private TaskData taskData;
+
+ @Override
+ protected void setUp() throws Exception {
+ repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, MockRepositoryConnector.REPOSITORY_URL);
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ taskData = new TaskData(new TaskAttributeMapper(repository), MockRepositoryConnector.CONNECTOR_KIND,
+ MockRepositoryConnector.REPOSITORY_URL, "taskId");
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository);
+ }
+
+ public void testMarkupAssociationFromRepository() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, ID_TEXTILE_EXTENSION);
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertTrue(extension instanceof MockTextileEditorExtension);
+ }
+
+ public void testMarkupAssociationFromAttribute() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, "none");
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ attribute.getMetaData().setMediaType("text/plain; markup=MockWiki");
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertTrue(extension instanceof MockWikiEditorExtension);
+ }
+
+ public void testMarkupAssociationFromBoth() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, ID_TEXTILE_EXTENSION);
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ attribute.getMetaData().setMediaType("text/plain; markup=MockWiki");
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertTrue(extension instanceof MockWikiEditorExtension);
+ }
+
+ public void testMarkupAssociationComplexMediaType() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, ID_TEXTILE_EXTENSION);
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ attribute.getMetaData().setMediaType("text/plain; markup=MockWiki; charset=iso-8859-1");
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertTrue(extension instanceof MockWikiEditorExtension);
+ }
+
+ public void testMarkupAssociationNotMarkupMediaType() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, ID_TEXTILE_EXTENSION);
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ attribute.getMetaData().setMediaType("text/plain; notreallyamarkup=MockWiki");
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertTrue(extension instanceof MockTextileEditorExtension);
+ }
+
+ public void testMarkupAssociationNoAssociation() {
+ TaskEditorExtensions.setTaskEditorExtensionId(repository, "none");
+ TaskAttribute attribute = taskData.getRoot().createMappedAttribute(TaskAttribute.DESCRIPTION);
+ AbstractTaskEditorExtension extension = TaskEditorExtensions.getTaskEditorExtension(repository, attribute);
+ assertNull(extension);
+ }
+
+}

Back to the top