32
32
public class ShortcutTest extends AbstractMemcheckTest {
36
public void setUp() throws Exception {
38
proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$
43
public void tearDown() throws CoreException {
48
public void testShortcutSelection() throws Exception {
49
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
51
shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
52
ILaunchConfiguration config = shortcut.getConfig();
54
compareWithDefaults(config);
57
public void testShortcutEditor() throws Exception {
58
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
60
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
61
IFile file = proj.getProject().getFile("test.c"); //$NON-NLS-1$
62
IEditorPart editor = IDE.openEditor(page, file);
64
assertNotNull(editor);
66
shortcut.launch(editor, ILaunchManager.PROFILE_MODE);
67
ILaunchConfiguration config = shortcut.getConfig();
69
compareWithDefaults(config);
72
public void testShortcutExistingConfig() throws Exception {
73
ILaunchConfiguration prev = createConfiguration(proj.getProject());
75
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
76
shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
77
ILaunchConfiguration current = shortcut.getConfig();
79
assertEquals(prev, current);
82
private void compareWithDefaults(ILaunchConfiguration config)
83
throws CoreException {
84
// tests launch in foreground, this is not typical
85
ILaunchConfiguration defaults = createConfiguration(proj.getProject());
86
ILaunchConfigurationWorkingCopy wc = defaults.getWorkingCopy();
87
wc.removeAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND);
90
// Compare launch config with defaults
91
assertEquals(config.getAttributes(), defaults.getAttributes());
35
public void prep() throws Exception {
36
proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$
41
public void tearDown() throws CoreException {
46
public void testShortcutSelection() throws Exception {
47
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
49
shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
50
ILaunchConfiguration config = shortcut.getConfig();
52
compareWithDefaults(config);
55
public void testShortcutEditor() throws Exception {
56
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
58
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
59
IFile file = proj.getProject().getFile("test.c"); //$NON-NLS-1$
60
IEditorPart editor = IDE.openEditor(page, file);
62
assertNotNull(editor);
64
shortcut.launch(editor, ILaunchManager.PROFILE_MODE);
65
ILaunchConfiguration config = shortcut.getConfig();
67
compareWithDefaults(config);
70
public void testShortcutExistingConfig() throws Exception {
71
ILaunchConfiguration prev = createConfiguration(proj.getProject());
73
ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
74
shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
75
ILaunchConfiguration current = shortcut.getConfig();
77
assertEquals(prev, current);
80
private void compareWithDefaults(ILaunchConfiguration config)
81
throws CoreException {
82
// tests launch in foreground, this is not typical
83
ILaunchConfiguration defaults = createConfiguration(proj.getProject());
84
ILaunchConfigurationWorkingCopy wc = defaults.getWorkingCopy();
85
wc.removeAttribute(IDebugUIConstants.ATTR_LAUNCH_IN_BACKGROUND);
88
// Compare launch config with defaults
89
assertEquals(config.getAttributes(), defaults.getAttributes());