Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorSteffen Pingel2013-06-27 15:25:00 +0000
committerSteffen Pingel2013-06-28 12:49:17 +0000
commit41bfa30a421f1051ef38c4946eb31ecd253b2226 (patch)
treedc3109bc38013136e7e95d4dfc6b497a27f713f0 /org.eclipse.mylyn.tasks.tests
parent7d54bbdcace41210385cab6463fae1f096231866 (diff)
downloadorg.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.tar.gz
org.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.tar.xz
org.eclipse.mylyn.tasks-41bfa30a421f1051ef38c4946eb31ecd253b2226.zip
408511: [api] add support for contributing UI and branding at runtime
Change-Id: I33c608dad60ee5d979e2ddd5c5cde4c386519610 Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=408511
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/core/RepositoryConnectorContributorTest.java27
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/support/MockRepositoryConnectorAdapter.java74
-rw-r--r--org.eclipse.mylyn.tasks.tests/testdata/icons/mock-overlay.gifbin0 -> 169 bytes
-rw-r--r--org.eclipse.mylyn.tasks.tests/testdata/icons/mock-repository.gifbin0 -> 224 bytes
5 files changed, 114 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/plugin.xml b/org.eclipse.mylyn.tasks.tests/plugin.xml
index 25485ebd8..a2c0b0b6c 100644
--- a/org.eclipse.mylyn.tasks.tests/plugin.xml
+++ b/org.eclipse.mylyn.tasks.tests/plugin.xml
@@ -213,5 +213,18 @@
class="org.eclipse.mylyn.tasks.tests.support.MockRepositoryConnectorContributor">
</contributor>
</extension>
+ <extension
+ point="org.eclipse.core.runtime.adapters">
+ <factory
+ adaptableType="org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector"
+ class="org.eclipse.mylyn.tasks.tests.support.MockRepositoryConnectorAdapter">
+ <adapter
+ type="org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi">
+ </adapter>
+ <adapter
+ type="org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorBranding">
+ </adapter>
+ </factory>
+ </extension>
</plugin>
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/RepositoryConnectorContributorTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/RepositoryConnectorContributorTest.java
index 80a92345b..4c6e19b89 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/RepositoryConnectorContributorTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/core/RepositoryConnectorContributorTest.java
@@ -13,9 +13,14 @@ package org.eclipse.mylyn.tasks.tests.core;
import junit.framework.TestCase;
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.support.MockRepositoryConnectorAdapter.DynamicMockRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.tests.support.MockRepositoryConnectorDescriptor.DynamicMockRepositoryConnector;
+import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.ui.TasksUi;
+import org.eclipse.swt.graphics.Image;
import org.junit.Test;
public class RepositoryConnectorContributorTest extends TestCase {
@@ -28,4 +33,26 @@ public class RepositoryConnectorContributorTest extends TestCase {
assertEquals(DynamicMockRepositoryConnector.CONNECTOR_KIND, connector.getConnectorKind());
}
+ @Test
+ public void testConnectorUiContributed() {
+ AbstractRepositoryConnectorUi connector = TasksUi.getRepositoryConnectorUi(DynamicMockRepositoryConnector.CONNECTOR_KIND);
+ assertNotNull("Expected connector UI contributed by MockRepositoryConnectorAdapter", connector);
+ assertEquals(DynamicMockRepositoryConnectorUi.class, connector.getClass());
+ assertEquals(DynamicMockRepositoryConnector.CONNECTOR_KIND, connector.getConnectorKind());
+ }
+
+ @Test
+ public void testMockBrandingIcon() {
+ Image brandingImage = TasksUiPlugin.getDefault().getBrandingIcon(DynamicMockRepositoryConnector.CONNECTOR_KIND);
+ assertNotNull("Expected branding image contributed by MockRepositoryConnectorAdapter", brandingImage);
+ }
+
+ @Test
+ public void testMockOverlayIcon() {
+ ImageDescriptor overlay = TasksUiPlugin.getDefault().getOverlayIcon(
+ DynamicMockRepositoryConnector.CONNECTOR_KIND);
+ assertNotNull("Expected overlay image contributed by MockRepositoryConnectorAdapter", overlay);
+ assertEquals(8, overlay.getImageData().height);
+ }
+
}
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/support/MockRepositoryConnectorAdapter.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/support/MockRepositoryConnectorAdapter.java
new file mode 100644
index 000000000..0956f155d
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/support/MockRepositoryConnectorAdapter.java
@@ -0,0 +1,74 @@
+/*******************************************************************************
+ * 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.support;
+
+import java.io.IOException;
+import java.io.InputStream;
+
+import org.eclipse.core.runtime.IAdapterFactory;
+import org.eclipse.mylyn.commons.sdk.util.CommonTestUtil;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
+import org.eclipse.mylyn.tasks.core.spi.RepositoryConnectorBranding;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
+import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnectorUi;
+import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
+
+public class MockRepositoryConnectorAdapter implements IAdapterFactory {
+
+ public final static class DynamicMockRepositoryConnectorUi extends MockRepositoryConnectorUi {
+
+ private final AbstractRepositoryConnector connector;
+
+ DynamicMockRepositoryConnectorUi(AbstractRepositoryConnector connector) {
+ this.connector = connector;
+ }
+
+ @Override
+ public String getConnectorKind() {
+ return connector.getConnectorKind();
+ }
+
+ }
+
+ private static final Class<?>[] ADAPTER_LIST = new Class<?>[] { AbstractRepositoryConnector.class };
+
+ @Override
+ public Object getAdapter(Object adaptableObject, @SuppressWarnings("rawtypes")
+ Class adapterType) {
+ if (adaptableObject instanceof MockRepositoryConnector) {
+ final AbstractRepositoryConnector connector = (AbstractRepositoryConnector) adaptableObject;
+ if (adapterType == AbstractRepositoryConnectorUi.class) {
+ return new DynamicMockRepositoryConnectorUi(connector);
+ } else if (adapterType == RepositoryConnectorBranding.class) {
+ return new RepositoryConnectorBranding() {
+ @Override
+ public InputStream getOverlayImageData() throws IOException {
+ return CommonTestUtil.getResource(this, "testdata/icons/mock-overlay.gif");
+ }
+
+ @Override
+ public InputStream getBrandingImageData() throws IOException {
+ return CommonTestUtil.getResource(this, "testdata/icons/mock-repository.gif");
+ }
+ };
+ }
+ }
+ return null;
+ }
+
+ @SuppressWarnings("rawtypes")
+ @Override
+ public Class[] getAdapterList() {
+ return ADAPTER_LIST;
+ }
+
+}
diff --git a/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-overlay.gif b/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-overlay.gif
new file mode 100644
index 000000000..5494ff788
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-overlay.gif
Binary files differ
diff --git a/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-repository.gif b/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-repository.gif
new file mode 100644
index 000000000..1dcbaaff9
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/testdata/icons/mock-repository.gif
Binary files differ

Back to the top