Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorColin Ritchie2016-08-11 23:46:34 +0000
committerGerrit Code Review @ Eclipse.org2016-08-12 21:37:03 +0000
commit4b77d3f2081127abd2ee27500d84b7bd94d8ff70 (patch)
treebb78c02569f8d7617638cdfc0435bdfeddaae8d4 /org.eclipse.mylyn.tasks.tests
parent87d261761bc06e87322fdd61d94b264f451c4518 (diff)
downloadorg.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.tar.gz
org.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.tar.xz
org.eclipse.mylyn.tasks-4b77d3f2081127abd2ee27500d84b7bd94d8ff70.zip
499581: Task Image is different when the task is owned by the user
Introduce the "Golden Clipboard" for tasks owned by the active user. Change-Id: I4fed0b3dccf3b2e1199e792881ca369f9490903e Task-Url: https://bugs.eclipse.org/bugs/show_bug.cgi?id=499581
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java9
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java56
2 files changed, 62 insertions, 3 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
index e18e6e4e7..7424fd259 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/connector/MockRepositoryConnectorUi.java
@@ -19,6 +19,7 @@ import java.util.regex.Pattern;
import org.eclipse.jface.text.Region;
import org.eclipse.jface.text.hyperlink.IHyperlink;
import org.eclipse.jface.wizard.IWizard;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.IRepositoryQuery;
import org.eclipse.mylyn.tasks.core.ITaskMapping;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -34,6 +35,14 @@ public class MockRepositoryConnectorUi extends AbstractRepositoryConnectorUi {
private static Pattern HYPERLINK_PATTERN = Pattern.compile("(\\d+)");
+ public MockRepositoryConnectorUi() {
+ super();
+ }
+
+ public MockRepositoryConnectorUi(AbstractRepositoryConnector connector) {
+ super(connector);
+ }
+
@Override
public String getConnectorKind() {
return "mock";
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
index fb75222ee..8083794b8 100644
--- a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/ui/AbstractRepositoryConnectorUiTest.java
@@ -11,10 +11,13 @@
package org.eclipse.mylyn.tasks.tests.ui;
-import junit.framework.TestCase;
-
+import org.eclipse.jface.resource.ImageDescriptor;
+import org.eclipse.mylyn.commons.net.AuthenticationCredentials;
+import org.eclipse.mylyn.commons.net.AuthenticationType;
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
import org.eclipse.mylyn.internal.tasks.core.TaskTask;
+import org.eclipse.mylyn.internal.tasks.ui.TasksUiPlugin;
+import org.eclipse.mylyn.tasks.core.AbstractRepositoryConnector;
import org.eclipse.mylyn.tasks.core.ITask;
import org.eclipse.mylyn.tasks.core.ITaskComment;
import org.eclipse.mylyn.tasks.core.TaskRepository;
@@ -25,6 +28,9 @@ import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnector;
import org.eclipse.mylyn.tasks.tests.connector.MockRepositoryConnectorUi;
import org.eclipse.mylyn.tasks.tests.connector.MockTask;
import org.eclipse.mylyn.tasks.ui.AbstractRepositoryConnectorUi;
+import org.eclipse.mylyn.tasks.ui.TasksUiImages;
+
+import junit.framework.TestCase;
/**
* @author Benjamin Muskalla
@@ -41,7 +47,8 @@ public class AbstractRepositoryConnectorUiTest extends TestCase {
@Override
protected void setUp() throws Exception {
- connectorUi = new MockRepositoryConnectorUi();
+ AbstractRepositoryConnector connector = new MockRepositoryConnector();
+ connectorUi = new MockRepositoryConnectorUi(connector);
repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, MockRepositoryConnector.REPOSITORY_URL);
task = new MockTask("1");
TaskAttributeMapper mapper = new TaskAttributeMapper(repository);
@@ -77,4 +84,47 @@ public class AbstractRepositoryConnectorUiTest extends TestCase {
String replyText = connectorUi.getReplyText(null, task, taskComment, true);
assertEquals("(In reply to 1 comment #13)", replyText);
}
+
+ public void testGetImageDescriptor() {
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("TaskOwner");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK, desc);
+ }
+
+ public void testGetImageDescriptorOwnedByMe() {
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url");
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("RepoUser", "SecretPassword"), false);
+ try {
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("RepoUser");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK_OWNED, desc);
+ } finally {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository);
+ }
+ }
+
+ public void testGetImageDescriptorOwnedNotByMe() {
+ TaskRepository repository = new TaskRepository(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url");
+ repository.setCredentials(AuthenticationType.REPOSITORY,
+ new AuthenticationCredentials("RepoUser", "SecretPassword"), false);
+ try {
+ TasksUiPlugin.getRepositoryManager().addRepository(repository);
+ ITask task = new TaskTask(MockRepositoryConnector.CONNECTOR_KIND, "http://connector.url", "1");
+ task.setOwner("AnotherRepoUser");
+
+ ImageDescriptor desc = connectorUi.getImageDescriptor(task);
+ assertNotNull(desc);
+ assertEquals(TasksUiImages.TASK, desc);
+ } finally {
+ TasksUiPlugin.getRepositoryManager().removeRepository(repository);
+ }
+ }
}

Back to the top