Search in sources :

Example 16 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class ExpandCollapseTest method testCollapse.

@Test
public void testCollapse() throws Exception {
    // Expand the element first
    testExpand();
    // Then collapse it
    IValgrindMessage[] messages = (IValgrindMessage[]) viewer.getTreeViewer().getInput();
    IValgrindMessage element = messages[0];
    TreeSelection selection = new TreeSelection(new TreePath(new Object[] { element }));
    viewer.getTreeViewer().setSelection(selection);
    contextMenu.notifyListeners(SWT.Show, null);
    contextMenu.getItem(1).notifyListeners(SWT.Selection, null);
    checkExpanded(element, false);
}
Also used : IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) TreePath(org.eclipse.jface.viewers.TreePath) TreeSelection(org.eclipse.jface.viewers.TreeSelection) Test(org.junit.Test)

Example 17 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class LaunchConfigTabTest method testValgrindError.

@Test
public void testValgrindError() throws Exception {
    // $NON-NLS-1$
    String notExistentFile = "DOES NOT EXIST";
    ILaunchConfigurationWorkingCopy wc = initConfig();
    tab.getSuppFileList().add(notExistentFile);
    tab.performApply(wc);
    config = wc.doSave();
    assertFalse(tab.isValid(config));
    // $NON-NLS-1$
    doLaunch(config, "testValgrindError");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IValgrindMessage[] messages = view.getMessages();
    assertTrue(messages.length > 0);
    String text = messages[0].getText();
    assertTrue(text.contains(notExistentFile));
}
Also used : ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ILaunchConfigurationWorkingCopy(org.eclipse.debug.core.ILaunchConfigurationWorkingCopy) Test(org.junit.Test)

Example 18 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class LinkedResourceMarkerTest method testLinkedMarkers.

@Test
public void testLinkedMarkers() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testLinkedMarkers");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IValgrindMessage[] errors = view.getMessages();
    ArrayList<IMarker> markers = new ArrayList<>(Arrays.asList(proj.getProject().findMarkers(ValgrindLaunchPlugin.MARKER_TYPE, true, IResource.DEPTH_INFINITE)));
    assertEquals(5, markers.size());
    for (IValgrindMessage error : errors) {
        findMarker(markers, error);
    }
    assertEquals(0, markers.size());
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ArrayList(java.util.ArrayList) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Example 19 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class MarkerTest method testMarkers.

@Test
public void testMarkers() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDefaults");
    ValgrindViewPart view = ValgrindUIPlugin.getDefault().getView();
    IValgrindMessage[] errors = view.getMessages();
    ArrayList<IMarker> markers = new ArrayList<>(Arrays.asList(proj.getProject().findMarkers(ValgrindLaunchPlugin.MARKER_TYPE, true, IResource.DEPTH_INFINITE)));
    assertEquals(5, markers.size());
    for (IValgrindMessage error : errors) {
        findMarker(markers, error);
    }
    assertEquals(0, markers.size());
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ValgrindViewPart(org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ArrayList(java.util.ArrayList) IMarker(org.eclipse.core.resources.IMarker) Test(org.junit.Test)

Example 20 with IValgrindMessage

use of org.eclipse.linuxtools.valgrind.core.IValgrindMessage in project linuxtools by eclipse.

the class MarkerTest method findMarker.

private void findMarker(ArrayList<IMarker> markers, IValgrindMessage error) throws Exception, CoreException {
    ValgrindStackFrame frame = null;
    IValgrindMessage[] children = error.getChildren();
    for (int i = 0; i < children.length; i++) {
        if (frame == null && children[i] instanceof ValgrindStackFrame && isWorkspaceFrame((ValgrindStackFrame) children[i])) {
            frame = (ValgrindStackFrame) children[i];
        } else if (children[i] instanceof ValgrindError) {
            findMarker(markers, children[i]);
        }
    }
    int ix = -1;
    for (int i = 0; i < markers.size(); i++) {
        IMarker marker = markers.get(i);
        if (marker.getAttribute(IMarker.MESSAGE).equals(error.getText()) && marker.getResource().getName().equals(frame.getFile()) && marker.getAttribute(IMarker.LINE_NUMBER).equals(frame.getLine())) {
            ix = i;
        }
    }
    assertFalse(ix < 0);
    markers.remove(ix);
}
Also used : ValgrindError(org.eclipse.linuxtools.internal.valgrind.core.ValgrindError) IValgrindMessage(org.eclipse.linuxtools.valgrind.core.IValgrindMessage) ValgrindStackFrame(org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame) IMarker(org.eclipse.core.resources.IMarker)

Aggregations

IValgrindMessage (org.eclipse.linuxtools.valgrind.core.IValgrindMessage)24 ValgrindStackFrame (org.eclipse.linuxtools.internal.valgrind.core.ValgrindStackFrame)10 ValgrindViewPart (org.eclipse.linuxtools.internal.valgrind.ui.ValgrindViewPart)10 Test (org.junit.Test)9 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)6 ArrayList (java.util.ArrayList)5 IMarker (org.eclipse.core.resources.IMarker)5 TreePath (org.eclipse.jface.viewers.TreePath)4 TreeSelection (org.eclipse.jface.viewers.TreeSelection)4 ValgrindError (org.eclipse.linuxtools.internal.valgrind.core.ValgrindError)4 IFile (org.eclipse.core.resources.IFile)3 CoreException (org.eclipse.core.runtime.CoreException)3 IPath (org.eclipse.core.runtime.IPath)3 File (java.io.File)2 IOException (java.io.IOException)2 URI (java.net.URI)2 IProject (org.eclipse.core.resources.IProject)2 IStatus (org.eclipse.core.runtime.IStatus)2 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)2 Status (org.eclipse.core.runtime.Status)2