Search in sources :

Example 11 with CachegrindOutput

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.

the class CModelLabelsTest method testFunctionLabel.

@Test
public void testFunctionLabel() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testFunctionLabel");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    CachegrindOutput output = view.getOutputs()[0];
    // $NON-NLS-1$
    CachegrindFile file = getFileByName(output, "cpptest.cpp");
    // $NON-NLS-1$
    CachegrindFunction func = getFunctionByName(file, "main");
    assertTrue(func.getModel() instanceof IFunction);
    checkLabelProvider(func, file);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindFunction(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) IFunction(org.eclipse.cdt.core.model.IFunction) Test(org.junit.Test)

Example 12 with CachegrindOutput

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.

the class CModelLabelsTest method testFileLabelsH.

@Test
public void testFileLabelsH() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testFileLabelsH");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    CachegrindOutput output = view.getOutputs()[0];
    // $NON-NLS-1$
    CachegrindFile file = getFileByName(output, "cpptest.h");
    assertTrue(file.getModel() instanceof ITranslationUnit);
    assertTrue(((ITranslationUnit) file.getModel()).isHeaderUnit());
    checkLabelProvider(file);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) ITranslationUnit(org.eclipse.cdt.core.model.ITranslationUnit) Test(org.junit.Test)

Example 13 with CachegrindOutput

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.

the class DoubleClickTest method testDoubleClickFunction.

@Test
public void testDoubleClickFunction() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDoubleClickFunction");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    CachegrindOutput output = view.getOutputs()[0];
    // $NON-NLS-1$
    CachegrindFile file = getFileByName(output, "cpptest.cpp");
    // $NON-NLS-1$
    CachegrindFunction func = getFunctionByName(file, "main");
    TreePath path = new TreePath(new Object[] { output, file, func });
    doDoubleClick(path);
    // check file in editor
    IEditorPart editor = checkFile(file);
    // check line number
    ITextEditor textEditor = (ITextEditor) editor;
    ISelection selection = textEditor.getSelectionProvider().getSelection();
    TextSelection textSelection = (TextSelection) selection;
    // zero-indexed
    int line = textSelection.getStartLine() + 1;
    int expectedLine = ((IFunction) func.getModel()).getSourceRange().getStartLine();
    assertEquals(expectedLine, line);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindFunction(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction) TextSelection(org.eclipse.jface.text.TextSelection) ISelection(org.eclipse.jface.viewers.ISelection) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) IEditorPart(org.eclipse.ui.IEditorPart) Test(org.junit.Test)

Example 14 with CachegrindOutput

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.

the class DoubleClickTest method testDoubleClickLine.

@Test
public void testDoubleClickLine() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDoubleClickFunction");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    CachegrindOutput output = view.getOutputs()[0];
    // $NON-NLS-1$
    CachegrindFile file = getFileByName(output, "cpptest.cpp");
    // $NON-NLS-1$
    CachegrindFunction func = getFunctionByName(file, "main");
    CachegrindLine line = func.getLines()[0];
    TreePath path = new TreePath(new Object[] { output, file, func });
    doDoubleClick(path);
    // check file in editor
    IEditorPart editor = checkFile(file);
    // check line number
    ITextEditor textEditor = (ITextEditor) editor;
    ISelection selection = textEditor.getSelectionProvider().getSelection();
    TextSelection textSelection = (TextSelection) selection;
    // zero-indexed
    int actualLine = textSelection.getStartLine() + 1;
    assertEquals(line.getLine(), actualLine);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) ITextEditor(org.eclipse.ui.texteditor.ITextEditor) TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) CachegrindFile(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile) CachegrindFunction(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction) TextSelection(org.eclipse.jface.text.TextSelection) ISelection(org.eclipse.jface.viewers.ISelection) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) CachegrindLine(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindLine) IEditorPart(org.eclipse.ui.IEditorPart) Test(org.junit.Test)

Example 15 with CachegrindOutput

use of org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput in project linuxtools by eclipse.

the class ExpandCollapseTest method testExpand.

@Test
public void testExpand() throws Exception {
    ILaunchConfiguration config = createConfiguration(proj.getProject());
    // $NON-NLS-1$
    doLaunch(config, "testDefaults");
    CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
    viewer = view.getViewer();
    contextMenu = viewer.getTree().getMenu();
    // Select first snapshot and expand it
    CachegrindOutput[] outputs = (CachegrindOutput[]) viewer.getInput();
    CachegrindOutput output = outputs[0];
    TreeSelection selection = new TreeSelection(new TreePath(new Object[] { output }));
    viewer.setSelection(selection);
    contextMenu.notifyListeners(SWT.Show, null);
    contextMenu.getItem(0).notifyListeners(SWT.Selection, null);
    checkExpanded(output, true);
}
Also used : ILaunchConfiguration(org.eclipse.debug.core.ILaunchConfiguration) TreePath(org.eclipse.jface.viewers.TreePath) CachegrindOutput(org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput) TreeSelection(org.eclipse.jface.viewers.TreeSelection) CachegrindViewPart(org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart) Test(org.junit.Test)

Aggregations

CachegrindOutput (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindOutput)17 Test (org.junit.Test)14 CachegrindViewPart (org.eclipse.linuxtools.internal.valgrind.cachegrind.CachegrindViewPart)13 CachegrindFile (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFile)13 ILaunchConfiguration (org.eclipse.debug.core.ILaunchConfiguration)11 CachegrindFunction (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindFunction)7 TreePath (org.eclipse.jface.viewers.TreePath)5 CachegrindLine (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.CachegrindLine)3 IMethod (org.eclipse.cdt.core.model.IMethod)2 ITranslationUnit (org.eclipse.cdt.core.model.ITranslationUnit)2 ILaunchConfigurationWorkingCopy (org.eclipse.debug.core.ILaunchConfigurationWorkingCopy)2 TextSelection (org.eclipse.jface.text.TextSelection)2 ISelection (org.eclipse.jface.viewers.ISelection)2 TreeSelection (org.eclipse.jface.viewers.TreeSelection)2 ICachegrindElement (org.eclipse.linuxtools.internal.valgrind.cachegrind.model.ICachegrindElement)2 IEditorPart (org.eclipse.ui.IEditorPart)2 ITextEditor (org.eclipse.ui.texteditor.ITextEditor)2 IFunction (org.eclipse.cdt.core.model.IFunction)1 IAdaptable (org.eclipse.core.runtime.IAdaptable)1 TreeViewer (org.eclipse.jface.viewers.TreeViewer)1