Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorspingel2007-11-21 21:17:43 +0000
committerspingel2007-11-21 21:17:43 +0000
commitde8d415884aca6bec93b8d4ba1fc7c7b955e3e36 (patch)
treedd8a8433562e3df129ecfd6e09d8544270860833 /org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
parente9e03c1d1198ebea0f44c19cf0b86f461795f992 (diff)
downloadorg.eclipse.mylyn.tasks-de8d415884aca6bec93b8d4ba1fc7c7b955e3e36.tar.gz
org.eclipse.mylyn.tasks-de8d415884aca6bec93b8d4ba1fc7c7b955e3e36.tar.xz
org.eclipse.mylyn.tasks-de8d415884aca6bec93b8d4ba1fc7c7b955e3e36.zip
NEW - bug 169426: create a new bug from a comment
https://bugs.eclipse.org/bugs/show_bug.cgi?id=169426
Diffstat (limited to 'org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java')
-rw-r--r--org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java97
1 files changed, 97 insertions, 0 deletions
diff --git a/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
new file mode 100644
index 000000000..0e95f155e
--- /dev/null
+++ b/org.eclipse.mylyn.tasks.tests/src/org/eclipse/mylyn/tasks/tests/NewTaskFromSelectionActionTest.java
@@ -0,0 +1,97 @@
+/*******************************************************************************
+ * Copyright (c) 2004, 2007 Mylyn project committers 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
+ *******************************************************************************/
+
+package org.eclipse.mylyn.tasks.tests;
+
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+import junit.framework.TestCase;
+
+import org.eclipse.jface.text.TextSelection;
+import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskFromSelectionAction;
+import org.eclipse.mylyn.internal.tasks.ui.editors.RepositoryTaskSelection;
+import org.eclipse.mylyn.tasks.core.AbstractAttributeFactory;
+import org.eclipse.mylyn.tasks.core.TaskComment;
+
+/**
+ * @author Frank Becker
+ * @author Steffen Pingel
+ */
+public class NewTaskFromSelectionActionTest extends TestCase {
+
+ public void testNoSelection() throws Exception {
+ NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
+ assertNull(action.getTaskSelection());
+ action.run();
+ action.selectionChanged(null);
+ assertNull(action.getTaskSelection());
+ }
+
+ public void testComment() throws Exception {
+ StubAttributeFactory targetFactory = new StubAttributeFactory();
+ TaskComment comment = new TaskComment(targetFactory, 1);
+
+ NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
+ action.selectionChanged(new RepositoryTaskSelection("id", "server", "kind", "", comment, "summary"));
+ assertNotNull(action.getTaskSelection());
+ }
+
+ public void testText() throws Exception {
+ NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
+ action.selectionChanged(new TextSelection(0, 0) {
+ @Override
+ public String getText() {
+ return "text";
+ }
+ });
+ assertNotNull(action.getTaskSelection());
+
+ action.selectionChanged(new TextSelection(0, 0));
+ assertNull(action.getTaskSelection());
+ }
+
+ private class StubAttributeFactory extends AbstractAttributeFactory {
+
+ private static final long serialVersionUID = 1L;
+
+ private Map<String, String> attributeMap = new HashMap<String, String>();
+
+ @Override
+ public Date getDateForAttributeType(String attributeKey, String dateString) {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public String getName(String key) {
+ // ignore
+ return null;
+ }
+
+ @Override
+ public boolean isHidden(String key) {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public boolean isReadOnly(String key) {
+ // ignore
+ return false;
+ }
+
+ @Override
+ public String mapCommonAttributeKey(String key) {
+ String mappedKey = attributeMap.get(key);
+ return (mappedKey != null) ? mappedKey : key;
+ }
+
+ }
+}

Back to the top