Skip to main content
summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2010-10-13 20:30:24 +0000
committerPawel Piech2010-10-13 20:30:24 +0000
commitcd4a924f62c764af8c74879580aacadf7e79765e (patch)
tree374298ee5b8a047d03957158d0621bb9ec216f64 /org.eclipse.debug.tests
parent0a6a09c545aaa5fd8ec6b242787be87024d4be8d (diff)
downloadeclipse.platform.debug-cd4a924f62c764af8c74879580aacadf7e79765e.tar.gz
eclipse.platform.debug-cd4a924f62c764af8c74879580aacadf7e79765e.tar.xz
eclipse.platform.debug-cd4a924f62c764af8c74879580aacadf7e79765e.zip
Bug 327557 - test failure: testRestoreRevealAfterRevealCancel2
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java43
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java4
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java55
3 files changed, 84 insertions, 18 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
index bcca99001..8f887c23e 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerTopIndexTests.java
@@ -19,6 +19,7 @@ import org.eclipse.core.commands.ExecutionException;
import org.eclipse.core.runtime.Platform;
import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDeltaVisitor;
import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
@@ -80,7 +81,7 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
}
protected ITreeModelContentProviderTarget getCTargetViewer() {
- return fViewer;
+ return (ITreeModelContentProviderTarget)fViewer;
}
protected TreeModelViewer createViewer(Display display, Shell shell) {
@@ -148,7 +149,7 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// check if REVEAL was restored OK
final TreePath topPath = getCTargetViewer().getTopElementPath();
Assert.assertNotNull("Top item should not be null!", topPath);
- Assert.assertEquals(originalTopPath, topPath);
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
}
/**
@@ -241,8 +242,7 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// check if REVEAL was restored OK
final TreePath topPath = getCTargetViewer().getTopElementPath();
Assert.assertNotNull("Top item should not be null!", topPath);
- Assert.assertEquals(originalTopPath, topPath);
-
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
}
/**
@@ -324,7 +324,7 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// check if REVEAL was restored OK
final TreePath topPath = getCTargetViewer().getTopElementPath();
Assert.assertNotNull("Top item should not be null!", topPath);
- Assert.assertEquals(originalTopPath, topPath);
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
}
/**
@@ -413,7 +413,8 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY, true);
- // Stop autopopulating the view.
+ // Stop auto-populating and auto-expanding the view.
+ fViewer.setAutoExpandLevel(0);
autopopulateAgent.dispose();
// Set top index of view to element "3" and wait for view to repaint.
@@ -428,7 +429,9 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// Set input back to root element.
// Note: Wait only for the processing of the delta and the start of state restore, not for all updates
fListener.reset();
- final TreePath elementPath = model.findElement("3");
+ TreePath elementPath = model.findElement("2");
+ fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 1, STATE_UPDATES | CHILDREN_UPDATES | LABEL_UPDATES);
+ elementPath = model.findElement("3");
fListener.addUpdates(fViewer, elementPath, model.getElement(elementPath), 0, STATE_UPDATES);
fViewer.setInput(model.getRootElement());
while (!fListener.isFinished(STATE_UPDATES))
@@ -437,22 +440,28 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// Update the viewer with new selection delta to something new in the view
TreePath pathToBeRevealed = model.findElement("2.1");
ModelDelta revealDelta = model.makeElementDelta(pathToBeRevealed, IModelDelta.REVEAL);
-
+ revealDelta.accept(new IModelDeltaVisitor() {
+
+ public boolean visit(IModelDelta delta, int depth) {
+ ((ModelDelta)delta).setFlags(delta.getFlags() | IModelDelta.EXPAND);
+ return true;
+ }
+ });
+
// Wait for the second model delta to process
- fListener.reset();
model.postDelta(revealDelta);
- while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_UPDATES_COMPLETE))
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CHILDREN_UPDATES | LABEL_UPDATES))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
-
- while (fDisplay.readAndDispatch ()) {}
- // check if REVEAL was restored OK
+
+ // check if REVEAL was triggered by the delta and not by the
+ // state restore operation
TreePath topPath = getCTargetViewer().getTopElementPath();
Assert.assertNotNull("Top item should not be null!", topPath);
- Assert.assertEquals(pathToBeRevealed, topPath);
-
+ TreePathWrapper.assertEqual(pathToBeRevealed, topPath);
}
+
/**
* Restore REVEAL when having also to restore an expanded element
* that is just above the REVEAL element.
@@ -504,8 +513,10 @@ public class JFaceViewerTopIndexTests extends TestCase implements ITestModelUpda
// check if REVEAL was restored OK
final TreePath topPath = getCTargetViewer().getTopElementPath();
Assert.assertNotNull("Top item should not be null!", topPath);
- Assert.assertEquals(originalTopPath, topPath);
+ TreePathWrapper.assertEqual(originalTopPath, topPath);
}
+
+
}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
index 0764542ca..739b8dc16 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java
@@ -286,8 +286,8 @@ public class TestModelUpdatesListener
fHasChildrenUpdatesScheduled.add(path);
}
- if ((flags & STATE_UPDATES) != 0 && viewer != null) {
- fStateUpdates.add(path);
+ if ((flags & STATE_UPDATES) != 0) {
+ fStateUpdates.add(path);
}
}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java
new file mode 100644
index 000000000..e45f72fd5
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TreePathWrapper.java
@@ -0,0 +1,55 @@
+package org.eclipe.debug.tests.viewer.model;
+
+import junit.framework.Assert;
+
+import org.eclipse.jface.viewers.TreePath;
+
+/**
+ * Utility for comparing TreePath objects in unit tests. This wrapper prints the tree
+ * paths in exception showing contexts of the paths.
+ *
+ * @since 3.7
+ */
+public class TreePathWrapper {
+ private final TreePath fPath;
+
+ public TreePathWrapper(TreePath path) {
+ fPath = path;
+ }
+
+ public int hashCode() {
+ return fPath.hashCode();
+ }
+
+ public boolean equals(Object obj) {
+ return obj instanceof TreePathWrapper &&
+ fPath.equals( ((TreePathWrapper)obj).fPath );
+ }
+
+ public String toString() {
+ if (fPath.getSegmentCount() == 0) {
+ return "TreePath:EMPTY";
+ }
+
+ StringBuffer buf = new StringBuffer("TreePath:[");
+
+ for (int i = 0; i < fPath.getSegmentCount(); i++) {
+ if (i != 0) {
+ buf.append(", ");
+ }
+ buf.append(fPath.getSegment(i));
+ }
+ buf.append(']');
+ return buf.toString();
+ }
+
+ /**
+ * Asserts that the two given tree paths are the same. In case of failure, the
+ * generated exception will contain a printout of the tree paths' contents.
+ */
+ public static void assertEqual(TreePath expected, TreePath actual) {
+ Assert.assertEquals(
+ expected != null ? new TreePathWrapper(expected) : null,
+ actual != null ? new TreePathWrapper(actual) : null);
+ }
+} \ No newline at end of file

Back to the top