Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorElliott Baron2009-03-16 14:59:49 +0000
committerElliott Baron2009-03-16 14:59:49 +0000
commit64aeaed3d39e400488a59e5aeacd739af0a5cd6d (patch)
tree1f5d88703fd0088b12351e60eec70ccd84812837 /valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests
parentb7e20b2cb8122f5c27e9f8ab47a131c56e8d5297 (diff)
downloadorg.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.tar.gz
org.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.tar.xz
org.eclipse.linuxtools-64aeaed3d39e400488a59e5aeacd739af0a5cd6d.zip
Extracted CachegrindLabelProvider
Diffstat (limited to 'valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests')
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog6
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF1
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java12
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java10
-rw-r--r--valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java87
5 files changed, 106 insertions, 10 deletions
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog
index a8c4256414..f83d91a9a4 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog
+++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/ChangeLog
@@ -1,3 +1,9 @@
+2009-03-16 Elliott Baron <ebaron@redhat.com>
+
+ * META-INF/MANIFEST.MF: Added cdt.ui to deps.
+ * AbstractCachegrindTest.java (getFileByName): Extracted method.
+ * BasicCachegrindTest.java: Likewise.
+
2009-03-13 Andrew Overholt <overholt@redhat.com>
* about.html: Initial checkin.
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF
index d491aa7b6b..b9dafc4122 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF
+++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/META-INF/MANIFEST.MF
@@ -12,6 +12,7 @@ Bundle-RequiredExecutionEnvironment: J2SE-1.5
Bundle-ActivationPolicy: lazy
Bundle-Localization: plugin
Import-Package: org.eclipse.cdt.core.model,
+ org.eclipse.cdt.ui,
org.eclipse.debug.core,
org.eclipse.debug.ui,
org.eclipse.linuxtools.profiling.tests,
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java
index 77bcb01e2b..eec7ca1460 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/AbstractCachegrindTest.java
@@ -11,6 +11,8 @@
package org.eclipse.linuxtools.valgrind.cachegrind.tests;
import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindPlugin;
+import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile;
+import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput;
import org.eclipse.linuxtools.valgrind.launch.IValgrindToolPage;
import org.eclipse.linuxtools.valgrind.tests.AbstractValgrindTest;
import org.osgi.framework.Bundle;
@@ -32,4 +34,14 @@ public abstract class AbstractCachegrindTest extends AbstractValgrindTest {
return new CachegrindTestToolPage();
}
+ protected CachegrindFile getFileByName(CachegrindOutput output, String name) {
+ CachegrindFile file = null;
+ for (CachegrindFile f : output.getFiles()) {
+ if (f.getName().equals(name)) {
+ file = f;
+ }
+ }
+ return file;
+ }
+
}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java
index 715186088a..3830671f7a 100644
--- a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java
+++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/BasicCachegrindTest.java
@@ -64,14 +64,4 @@ public class BasicCachegrindTest extends AbstractCachegrindTest {
assertNotNull(file);
assertEquals(8, file.getFunctions().length);
}
-
- private CachegrindFile getFileByName(CachegrindOutput output, String name) {
- CachegrindFile file = null;
- for (CachegrindFile f : output.getFiles()) {
- if (f.getName().equals(name)) {
- file = f;
- }
- }
- return file;
- }
}
diff --git a/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java
new file mode 100644
index 0000000000..671be45b48
--- /dev/null
+++ b/valgrind/org.eclipse.linuxtools.valgrind.cachegrind.tests/src/org/eclipse/linuxtools/valgrind/cachegrind/tests/TableTest.java
@@ -0,0 +1,87 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Red Hat, Inc.
+ * 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:
+ * Elliott Baron <ebaron@redhat.com> - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.linuxtools.valgrind.cachegrind.tests;
+
+import org.eclipse.cdt.core.model.IBinary;
+import org.eclipse.cdt.core.model.ITranslationUnit;
+import org.eclipse.cdt.ui.CElementLabelProvider;
+import org.eclipse.debug.core.ILaunchConfiguration;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.jface.viewers.TreeViewer;
+import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindLabelProvider;
+import org.eclipse.linuxtools.valgrind.cachegrind.CachegrindViewPart;
+import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindFile;
+import org.eclipse.linuxtools.valgrind.cachegrind.model.CachegrindOutput;
+import org.eclipse.linuxtools.valgrind.ui.ValgrindUIPlugin;
+import org.eclipse.swt.widgets.TreeItem;
+
+public class TableTest extends AbstractCachegrindTest {
+
+ @Override
+ protected void setUp() throws Exception {
+ super.setUp();
+ proj = createProject("cpptest"); //$NON-NLS-1$
+ }
+
+ @Override
+ protected void tearDown() throws Exception {
+ super.tearDown();
+ deleteProject(proj);
+ }
+
+ public void testFileLabelsCPP() throws Exception {
+ IBinary bin = proj.getBinaryContainer().getBinaries()[0];
+ ILaunchConfiguration config = createConfiguration(bin);
+ doLaunch(config, "testFileLabelsCPP"); //$NON-NLS-1$
+
+ CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
+ CachegrindOutput output = view.getOutputs()[0];
+ CachegrindFile file = getFileByName(output, "cpptest.cpp"); //$NON-NLS-1$
+
+ assertTrue(file.getModel() instanceof ITranslationUnit);
+
+ checkLabelProvider(file);
+ }
+
+ public void testFileLabelsH() throws Exception {
+ IBinary bin = proj.getBinaryContainer().getBinaries()[0];
+ ILaunchConfiguration config = createConfiguration(bin);
+ doLaunch(config, "testFileLabelsH"); //$NON-NLS-1$
+
+ CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
+ CachegrindOutput output = view.getOutputs()[0];
+ CachegrindFile file = getFileByName(output, "cpptest.h"); //$NON-NLS-1$
+
+ assertTrue(file.getModel() instanceof ITranslationUnit);
+ assertTrue(((ITranslationUnit) file.getModel()).isHeaderUnit());
+
+ checkLabelProvider(file);
+ }
+
+ private void checkLabelProvider(CachegrindFile file) {
+ CachegrindViewPart view = (CachegrindViewPart) ValgrindUIPlugin.getDefault().getView().getDynamicView();
+ TreeViewer viewer = view.getViewer();
+
+ // collapse the tree, then expand only the interesting item
+ viewer.expandToLevel(file, TreeViewer.ALL_LEVELS);
+ TreePath path = new TreePath(new Object[] { view.getOutputs()[0], file });
+ TreeSelection selection = new TreeSelection(path);
+ viewer.setSelection(selection);
+ TreeItem item = viewer.getTree().getSelection()[0];
+
+ // ensure the CElementLabelProvider is called correctly
+ CElementLabelProvider provider = ((CachegrindLabelProvider) viewer.getLabelProvider(0)).getCLabelProvider();
+ assertEquals(provider.getText(file.getModel()), item.getText());
+ assertEquals(provider.getImage(file.getModel()), item.getImage());
+ }
+
+}

Back to the top