aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Friederich2012-04-24 23:22:16 (EDT)
committerMike Rennie2012-04-24 23:22:16 (EDT)
commit3c37ebb13cc4bf89f3ec7128ac4ad24ffbcaaaeb (patch)
tree8ad3ab22971747b89a8b6ef325b1c8a8c450b35e
parenta3c9c21e30220dd39c41af0dddb1235146a1cc12 (diff)
downloadeclipse.platform.debug-3c37ebb13cc4bf89f3ec7128ac4ad24ffbcaaaeb.zip
eclipse.platform.debug-3c37ebb13cc4bf89f3ec7128ac4ad24ffbcaaaeb.tar.gz
eclipse.platform.debug-3c37ebb13cc4bf89f3ec7128ac4ad24ffbcaaaeb.tar.bz2
Bug 293618 - [tests][patch][breakpoints] Breakpoints view sorts up tov20120425-0322
first colon only
-rw-r--r--org.eclipse.debug.tests/META-INF/MANIFEST.MF1
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java6
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java5
-rw-r--r--org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java380
4 files changed, 388 insertions, 4 deletions
diff --git a/org.eclipse.debug.tests/META-INF/MANIFEST.MF b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
index e4b5c92..f295130 100644
--- a/org.eclipse.debug.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.debug.tests/META-INF/MANIFEST.MF
@@ -18,5 +18,6 @@ Export-Package: org.eclipe.debug.tests.launching,
org.eclipe.debug.tests.view.memory,
org.eclipe.debug.tests.viewer.model,
org.eclipse.debug.tests,
+ org.eclipse.debug.tests.breakpoint,
org.eclipse.debug.tests.expressions,
org.eclipse.debug.tests.statushandlers
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java
index 4fa370c..ab59222 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/launching/LaunchManagerTests.java
@@ -45,7 +45,7 @@ public class LaunchManagerTests extends AbstractLaunchTest {
*/
public void testGenereateConfigNameBadChar() {
String configname = "config:name";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
+ String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
assertEquals("config name should be '"+configname+"'", configname, name);
}
@@ -65,8 +65,8 @@ public class LaunchManagerTests extends AbstractLaunchTest {
public void testGenerateConfigNameReservedName() {
if(Platform.OS_WIN32.equals(Platform.getOS())) {
String configname = "aux";
- String name = getLaunchManager().generateLaunchConfigurationName(configname);
- assertEquals("config name should be '"+configname+"'", configname, name);
+ String name = getLaunchManager().generateUniqueLaunchConfigurationNameFrom(configname);
+ assertEquals("config name should be 'aux'", configname, name);
}
}
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
index a3cba9b..87fbb05 100644
--- a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/AutomatedSuite.java
@@ -1,5 +1,5 @@
/*******************************************************************************
- * Copyright (c) 2009, 2011 IBM Corporation and others.
+ * Copyright (c) 2009, 2012 IBM Corporation and others.
* 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
@@ -7,6 +7,7 @@
*
* Contributors:
* IBM Corporation - initial API and implementation
+ * Freescale Semiconductor - Bug 293618, Breakpoints view sorts up to first colon only
*******************************************************************************/
package org.eclipse.debug.tests;
@@ -30,6 +31,7 @@ import org.eclipe.debug.tests.viewer.model.VirtualViewerLazyModeTests;
import org.eclipe.debug.tests.viewer.model.VirtualViewerSelectionTests;
import org.eclipe.debug.tests.viewer.model.VirtualViewerStateTests;
import org.eclipe.debug.tests.viewer.model.VirtualViewerUpdateTests;
+import org.eclipse.debug.tests.breakpoint.BreakpointOrderingTests;
import org.eclipse.debug.tests.statushandlers.StatusHandlerTests;
/**
@@ -52,6 +54,7 @@ public class AutomatedSuite extends TestSuite {
* Constructs the automated test suite. Adds all tests.
*/
public AutomatedSuite() {
+ addTest(new TestSuite(BreakpointOrderingTests.class));
// Note: jface viewer tests were moved out of nightly tests
// due to frequent problems on nightly build machines.
// (Bug 343308).
diff --git a/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java
new file mode 100644
index 0000000..8a8a2a3
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipse/debug/tests/breakpoint/BreakpointOrderingTests.java
@@ -0,0 +1,380 @@
+/*******************************************************************************
+ * Copyright (c) 2000, 2009 IBM Corporation and others.
+ * 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:
+ * IBM Corporation - initial API and implementation
+ *******************************************************************************/
+package org.eclipse.debug.tests.breakpoint;
+
+import java.util.List;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipse.core.resources.IMarker;
+import org.eclipse.core.resources.IResource;
+import org.eclipse.core.resources.IWorkspaceRunnable;
+import org.eclipse.core.resources.ResourcesPlugin;
+import org.eclipse.core.runtime.CoreException;
+import org.eclipse.core.runtime.IProgressMonitor;
+import org.eclipse.core.runtime.IStatus;
+import org.eclipse.core.runtime.Status;
+import org.eclipse.debug.core.model.IBreakpoint;
+import org.eclipse.debug.core.model.ILineBreakpoint;
+import org.eclipse.debug.core.model.IValue;
+import org.eclipse.debug.internal.ui.views.breakpoints.BreakpointsComparator;
+import org.eclipse.debug.tests.TestsPlugin;
+import org.eclipse.debug.ui.IDebugModelPresentation;
+import org.eclipse.debug.ui.IValueDetailListener;
+import org.eclipse.jface.viewers.IBaseLabelProvider;
+import org.eclipse.jface.viewers.ILabelProviderListener;
+import org.eclipse.jface.viewers.StructuredViewer;
+import org.eclipse.swt.graphics.Image;
+import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Widget;
+import org.eclipse.ui.IEditorInput;
+
+/**
+ * Test the ordering used in the breakpoints view.
+ *
+ * Using a special Comparator which sorts breakpoint texts like file:1, file:2 and file:11 in a numerical ordering.
+ */
+public class BreakpointOrderingTests extends TestCase {
+
+ public BreakpointOrderingTests(String name) {
+ super(name);
+ }
+
+ /**
+ * Test only implementation of IBreakpoint.
+ */
+ static class TestBreakpoint implements IBreakpoint {
+
+ private String fText;
+ private IMarker fMarker = null;
+
+ TestBreakpoint(String text) {
+ this(text, IBreakpoint.BREAKPOINT_MARKER);
+ }
+
+ TestBreakpoint(String text, final String markerType) {
+ fText = text;
+ final IResource resource = ResourcesPlugin.getWorkspace().getRoot();
+ IWorkspaceRunnable wr = new IWorkspaceRunnable() {
+
+ public void run( IProgressMonitor monitor ) throws CoreException {
+ // create the marker
+ setMarker(resource.createMarker(markerType));
+ }
+ };
+ try {
+ ResourcesPlugin.getWorkspace().run( wr, null );
+ }
+ catch ( CoreException e ) {
+ Assert.fail("Unexpected exception: " + e.toString());
+ }
+
+ }
+
+ void ReportFailure(String msg) throws CoreException {
+ throw new CoreException(new Status(IStatus.ERROR, TestsPlugin.PLUGIN_ID, msg));
+ }
+
+
+ String getText() {
+ return fText;
+ }
+
+ public void delete() throws CoreException {
+ fMarker.delete();
+ }
+
+ public IMarker getMarker() {
+ return fMarker;
+ }
+
+ public String getModelIdentifier() {
+ return "Test";
+ }
+
+ public boolean isEnabled() throws CoreException {
+ Assert.fail("not implemented in test");
+ return false;
+ }
+
+ public boolean isPersisted() throws CoreException {
+ Assert.fail("not implemented in test");
+ return false;
+ }
+
+ public boolean isRegistered() throws CoreException {
+ Assert.fail("not implemented in test");
+ return false;
+ }
+
+ public void setEnabled(boolean enabled) throws CoreException {
+ Assert.fail("not implemented in test");
+ }
+
+ public void setMarker(IMarker marker) throws CoreException {
+ Assert.assertTrue(fMarker == null && marker != null);
+ fMarker = marker;
+ }
+
+ public void setPersisted(boolean registered) throws CoreException {
+ Assert.fail("not implemented in test");
+ }
+
+ public void setRegistered(boolean registered) throws CoreException {
+ Assert.fail("not implemented in test");
+
+ }
+
+ public Object getAdapter(Class adapter) {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ }
+
+ /**
+ * Test only implementation of ILineBreakpoint.
+ */
+ static class TestLineBreakpoint extends TestBreakpoint implements ILineBreakpoint {
+ private int fLineNum;
+
+ TestLineBreakpoint(String text, int lineNum) {
+ super(text, IBreakpoint.LINE_BREAKPOINT_MARKER);
+ fLineNum = lineNum;
+ }
+
+ public int getLineNumber() throws CoreException {
+ return fLineNum;
+ }
+
+ public int getCharEnd() throws CoreException {
+ Assert.fail("not implemented in test");
+ return 0;
+ }
+
+ public int getCharStart() throws CoreException {
+ Assert.fail("not implemented in test");
+ return 0;
+ }
+ }
+
+ /**
+ * Test only implementation of StructuredViewer.
+ */
+ StructuredViewer fTestViewer = new StructuredViewer() {
+
+ public IBaseLabelProvider getLabelProvider() {
+ return fDebugModelPres;
+ }
+
+ protected Widget doFindInputItem(Object element) {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ protected Widget doFindItem(Object element) {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ protected void doUpdateItem(Widget item, Object element, boolean fullMap) {
+ Assert.fail("not implemented in test");
+ }
+
+ protected List getSelectionFromWidget() {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ protected void internalRefresh(Object element) {
+ Assert.fail("not implemented in test");
+ }
+
+ public void reveal(Object element) {
+ Assert.fail("not implemented in test");
+ }
+
+ protected void setSelectionToWidget(List l, boolean reveal) {
+ Assert.fail("not implemented in test");
+ }
+
+ public Control getControl() {
+ Assert.fail("not implemented in test");
+ return null;
+ }};
+
+ // Test debug model presentation for label text retrieval.
+ IDebugModelPresentation fDebugModelPres = new IDebugModelPresentation() {
+
+ public void computeDetail(IValue value, IValueDetailListener listener) {
+ Assert.fail("not implemented in test");
+ }
+
+ public Image getImage(Object element) {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ public String getText(Object element) {
+ Assert.assertTrue("Unexpected element", element instanceof TestBreakpoint);
+ return ((TestBreakpoint)element).getText();
+ }
+
+ public void setAttribute(String attribute, Object value) {
+ Assert.fail("not implemented in test");
+ }
+
+ public void addListener(ILabelProviderListener listener) {
+ Assert.fail("not implemented in test");
+ }
+
+ public void dispose() {
+ Assert.fail("not implemented in test");
+ }
+
+ public boolean isLabelProperty(Object element, String property) {
+ Assert.fail("not implemented in test");
+ return false;
+ }
+
+ public void removeListener(ILabelProviderListener listener) {
+ Assert.fail("not implemented in test");
+ }
+
+ public String getEditorId(IEditorInput input, Object element) {
+ Assert.fail("not implemented in test");
+ return null;
+ }
+
+ public IEditorInput getEditorInput(Object element) {
+ Assert.fail("not implemented in test");
+ return null;
+ }};
+
+ // Test vector with some UNIX paths
+ TestBreakpoint[] createTestBreakpoints0() {
+ TestBreakpoint[] fTestBps = {
+ new TestBreakpoint(""),
+ new TestBreakpoint("/file/text.c"),
+ new TestBreakpoint("/file/text.c:1"),
+ new TestLineBreakpoint("", 0),
+ new TestLineBreakpoint("/file/text.c", 0),
+ new TestLineBreakpoint("/file/text.c", 1),
+ new TestLineBreakpoint("/file/text.c:", 0),
+ new TestLineBreakpoint("/file/text.c:0", 0),
+ new TestLineBreakpoint("/file/text.c:1", 1),
+ new TestLineBreakpoint("/file/text.c:0002", 2),
+ new TestLineBreakpoint("/file/text.c:3xxx", 3),
+ new TestLineBreakpoint("/file/text.c:10xxx", 10),
+ new TestLineBreakpoint("/file/text.c:a_01", 1),
+ new TestLineBreakpoint("/file/text.c:a_01a", 1),
+ new TestLineBreakpoint("/file/text.c:a_09", 9),
+ new TestLineBreakpoint("/file/text.c:a_09a", 9),
+ new TestLineBreakpoint("/file/text.c:a_011", 11),
+ new TestLineBreakpoint("/file/text.c:a_011a", 11),
+ new TestLineBreakpoint("/file/text.c:y", 0),
+ };
+ return fTestBps;
+ }
+
+ // Check plain numbers
+ TestBreakpoint[] createTestBreakpoints1() {
+ TestBreakpoint[] fTestBps = {
+ new TestLineBreakpoint("0", 0),
+ new TestLineBreakpoint("1", 1),
+ new TestLineBreakpoint("1_a", 1),
+ new TestLineBreakpoint("001_b", 1),
+ new TestLineBreakpoint("01_c", 1),
+ new TestLineBreakpoint("3", 3),
+ new TestLineBreakpoint("10", 10),
+ new TestLineBreakpoint("11", 11),
+ new TestLineBreakpoint("20", 20),
+ new TestLineBreakpoint("110", 110),
+ new TestLineBreakpoint("112", 112),
+ new TestLineBreakpoint("112a", 112),
+ new TestLineBreakpoint("112b", 112),
+ };
+ return fTestBps;
+ }
+
+ // Test consistent behavior with leading 0's
+ TestBreakpoint[] createTestBreakpoints2() {
+ TestBreakpoint[] fTestBps = {
+ new TestLineBreakpoint("0", 0),
+ new TestLineBreakpoint("00", 0),
+ new TestLineBreakpoint("0000", 0),
+ new TestLineBreakpoint("0001", 1),
+ new TestLineBreakpoint("0010", 10),
+ new TestLineBreakpoint("1000", 1000),
+ new TestLineBreakpoint("10000", 10000),
+ };
+ return fTestBps;
+ }
+
+ // Test Win32 paths
+ TestBreakpoint[] createTestBreakpoints3() {
+ TestBreakpoint[] fTestBps = {
+ new TestLineBreakpoint(":a", 0),
+ new TestLineBreakpoint("c:\\file\\text.c:1", 1),
+ new TestLineBreakpoint("c:\\file\\text.c:2", 2),
+ new TestLineBreakpoint("d:\\file\\text.c:3", 3),
+ };
+ return fTestBps;
+ }
+
+ public void testBreakpointOrdering0() throws CoreException {
+ executeTest(createTestBreakpoints0());
+ }
+ public void testBreakpointOrdering1() throws CoreException {
+ executeTest(createTestBreakpoints1());
+ }
+ public void testBreakpointOrdering2() throws CoreException {
+ executeTest(createTestBreakpoints2());
+ }
+ public void testBreakpointOrdering3() throws CoreException {
+ executeTest(createTestBreakpoints3());
+ }
+
+
+ /**
+ * Test expected ordering.
+ * Expecting the same ordering as in which the BP's are returned by createTestBreakpoints.
+ */
+ void executeTest(TestBreakpoint[] testBps) throws CoreException {
+ BreakpointsComparator bpCompare = new BreakpointsComparator();
+ try {
+ boolean failed = false;
+ for (int inner = 0; inner < testBps.length; inner++) {
+ TestBreakpoint testInner = testBps[inner];
+ for (int outer = 0; outer < testBps.length; outer++) {
+ TestBreakpoint testOuter = testBps[outer];
+ int res = bpCompare.compare(fTestViewer, testInner, testOuter);
+ boolean equalCheck = (res == 0) == (inner == outer);
+ boolean ltCheck = (res < 0) == (inner < outer);
+ if (!equalCheck) {
+ System.err.println("Equal Comparison in between " + inner + " and " + outer + " ("+testBps[inner].getText()+ " and "+testBps[outer].getText()+") failed" );
+ failed = true;
+ }
+ if (!ltCheck) {
+ System.err.println("Less Comparison in between " + inner + " and " + outer + " ("+testBps[inner].getText()+ " and "+testBps[outer].getText()+") failed" );
+ failed = true;
+ }
+ }
+ }
+ Assert.assertFalse(failed);
+ } finally {
+ for (int index = 0; index < testBps.length; index++) {
+ testBps[index].delete();
+ }
+ }
+ }
+} \ No newline at end of file