blob: 0060db199a6418f9292fe2b4db9d8a98b211e587 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
/*******************************************************************************
* Copyright (c) 2004, 2008 Frank Becker 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:
* Frank Becker - initial API and implementation
* Tasktop Technologies - improvements
*******************************************************************************/
package org.eclipse.mylyn.tasks.tests;
import junit.framework.TestCase;
import org.eclipse.jface.text.TextSelection;
import org.eclipse.jface.viewers.StructuredSelection;
import org.eclipse.mylyn.internal.tasks.core.TaskComment;
import org.eclipse.mylyn.internal.tasks.ui.actions.NewTaskFromSelectionAction;
import org.eclipse.mylyn.tasks.core.TaskRepository;
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.tests.connector.MockTask;
/**
* @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 {
TaskRepository taskRepository = new TaskRepository(MockRepositoryConnector.REPOSITORY_KIND,
MockRepositoryConnector.REPOSITORY_URL);
TaskData taskData = new TaskData(new TaskAttributeMapper(taskRepository), "kind", "http://url", "1");
TaskComment comment = new TaskComment(taskRepository, new MockTask("1"), taskData.getRoot().createAttribute(
"id"));
NewTaskFromSelectionAction action = new NewTaskFromSelectionAction();
action.selectionChanged(new StructuredSelection(comment));
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());
}
}
|