~ubuntu-branches/ubuntu/wily/eclipse-linuxtools/wily

« back to all changes in this revision

Viewing changes to valgrind/org.eclipse.linuxtools.valgrind.memcheck.tests/src/org/eclipse/linuxtools/internal/valgrind/memcheck/tests/ShortcutTest.java

  • Committer: Package Import Robot
  • Author(s): Jakub Adam, Jakub Adam, tony mancill
  • Date: 2014-10-11 11:44:05 UTC
  • mfrom: (1.2.4)
  • Revision ID: package-import@ubuntu.com-20141011114405-yazjvxfzzhmi5sgj
Tags: 3.1.0-1
[ Jakub Adam ]
* New upstream release (Closes: #761524).
* Refreshed d/patches.
* Don't build removed feature org.eclipse.linuxtools.tools.launch
  - merged into org.eclipse.linuxtools.profiling.
* Use javac target 1.7.
* Build new feature org.eclipse.linuxtools.dataviewers.feature
  - required by Valgrind integration.
* Build-depend on eclipse-remote-services-api and eclipse-cdt-autotools.
* Bump Standards-Version to 3.9.6.
* Override incompatible-java-bytecode-format - linuxtools needs Java 7.
* Remove unused codeless-jar override.

[ tony mancill ]
* Tweak short package description to make lintian happy.

Show diffs side-by-side

added added

removed removed

Lines of Context:
31
31
 
32
32
public class ShortcutTest extends AbstractMemcheckTest {
33
33
 
34
 
        @Override
35
 
        @Before
36
 
        public void setUp() throws Exception {
37
 
                super.setUp();
38
 
                proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$
39
 
        }
40
 
 
41
 
        @Override
42
 
        @After
43
 
        public void tearDown() throws CoreException {
44
 
                deleteProject(proj);
45
 
                super.tearDown();
46
 
        }
47
 
        @Test
48
 
        public void testShortcutSelection() throws Exception {
49
 
                ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
50
 
 
51
 
                shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
52
 
                ILaunchConfiguration config = shortcut.getConfig();
53
 
 
54
 
                compareWithDefaults(config);
55
 
        }
56
 
        @Test
57
 
        public void testShortcutEditor() throws Exception {
58
 
                ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
59
 
 
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);
63
 
 
64
 
                assertNotNull(editor);
65
 
 
66
 
                shortcut.launch(editor, ILaunchManager.PROFILE_MODE);
67
 
                ILaunchConfiguration config = shortcut.getConfig();
68
 
 
69
 
                compareWithDefaults(config);
70
 
        }
71
 
        @Test
72
 
        public void testShortcutExistingConfig() throws Exception {
73
 
                ILaunchConfiguration prev = createConfiguration(proj.getProject());
74
 
 
75
 
                ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
76
 
                shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
77
 
                ILaunchConfiguration current = shortcut.getConfig();
78
 
 
79
 
                assertEquals(prev, current);
80
 
        }
81
 
 
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);
88
 
                wc.doSave();
89
 
 
90
 
                // Compare launch config with defaults
91
 
                assertEquals(config.getAttributes(), defaults.getAttributes());
92
 
        }
 
34
    @Before
 
35
    public void prep() throws Exception {
 
36
        proj = createProjectAndBuild("basicTest"); //$NON-NLS-1$
 
37
    }
 
38
 
 
39
    @Override
 
40
    @After
 
41
    public void tearDown() throws CoreException {
 
42
        deleteProject(proj);
 
43
        super.tearDown();
 
44
    }
 
45
    @Test
 
46
    public void testShortcutSelection() throws Exception {
 
47
        ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
 
48
 
 
49
        shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
 
50
        ILaunchConfiguration config = shortcut.getConfig();
 
51
 
 
52
        compareWithDefaults(config);
 
53
    }
 
54
    @Test
 
55
    public void testShortcutEditor() throws Exception {
 
56
        ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
 
57
 
 
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);
 
61
 
 
62
        assertNotNull(editor);
 
63
 
 
64
        shortcut.launch(editor, ILaunchManager.PROFILE_MODE);
 
65
        ILaunchConfiguration config = shortcut.getConfig();
 
66
 
 
67
        compareWithDefaults(config);
 
68
    }
 
69
    @Test
 
70
    public void testShortcutExistingConfig() throws Exception {
 
71
        ILaunchConfiguration prev = createConfiguration(proj.getProject());
 
72
 
 
73
        ValgrindTestLaunchShortcut shortcut = new ValgrindTestLaunchShortcut();
 
74
        shortcut.launch(new StructuredSelection(proj.getProject()), ILaunchManager.PROFILE_MODE);
 
75
        ILaunchConfiguration current = shortcut.getConfig();
 
76
 
 
77
        assertEquals(prev, current);
 
78
    }
 
79
 
 
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);
 
86
        wc.doSave();
 
87
 
 
88
        // Compare launch config with defaults
 
89
        assertEquals(config.getAttributes(), defaults.getAttributes());
 
90
    }
93
91
}