Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2010-03-30 23:51:46 +0000
committerPawel Piech2010-03-30 23:51:46 +0000
commit6a27be2e48a3a2ed7a1790e16a112a2c5746939b (patch)
tree081f951b89f9503a88967241e227b42538f7d02d /org.eclipse.debug.tests
parent5250ea198e7067330a2fd3f002a32db6844214be (diff)
downloadeclipse.platform.debug-6a27be2e48a3a2ed7a1790e16a112a2c5746939b.tar.gz
eclipse.platform.debug-6a27be2e48a3a2ed7a1790e16a112a2c5746939b.tar.xz
eclipse.platform.debug-6a27be2e48a3a2ed7a1790e16a112a2c5746939b.zip
Bug 307162 - [flex-hierarhcy] Tree viewer does not update when created with the POPUP style flag
Diffstat (limited to 'org.eclipse.debug.tests')
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java81
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java37
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java32
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java245
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java2
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModelUpdatesListener.java36
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java33
7 files changed, 428 insertions, 38 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
index f71982d79..9e9662f2b 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/DeltaTests.java
@@ -34,7 +34,7 @@ import org.eclipse.ui.PlatformUI;
* Tests to verify that the viewer property retrieves and processes the
* model deltas generated by the test model.
*/
-abstract public class DeltaTests extends TestCase {
+abstract public class DeltaTests extends TestCase implements ITestModelUpdatesListenerConstants {
Display fDisplay;
Shell fShell;
ITreeModelViewer fViewer;
@@ -103,7 +103,7 @@ abstract public class DeltaTests extends TestCase {
fListener.reset(elementPath, element, -1, true, false);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.LABEL_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(LABEL_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
@@ -183,7 +183,7 @@ abstract public class DeltaTests extends TestCase {
fListener.reset(TreePath.EMPTY, element, -1, false, false);
model.postDelta(new ModelDelta(element, IModelDelta.CONTENT));
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
@@ -218,7 +218,7 @@ abstract public class DeltaTests extends TestCase {
// TODO: redundant label updates on insert!
fListener.setFailOnRedundantUpdates(false);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
@@ -313,7 +313,7 @@ abstract public class DeltaTests extends TestCase {
fListener.setFailOnRedundantUpdates(false);
model.postDelta(combinedDelta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
@@ -345,7 +345,7 @@ abstract public class DeltaTests extends TestCase {
// TODO: redundant updates on add!
fListener.setFailOnRedundantUpdates(false);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
@@ -372,7 +372,7 @@ abstract public class DeltaTests extends TestCase {
// be processed.
fListener.reset();
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
}
@@ -438,7 +438,7 @@ abstract public class DeltaTests extends TestCase {
Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3_2_2));
model.postDelta(deltaRoot);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY, true);
@@ -457,6 +457,63 @@ abstract public class DeltaTests extends TestCase {
}
}
+ /**
+ * This test verifies that expand and select updates are being ignored.
+ */
+ public void testExpandAndSelect_simple() {
+ TestModel model = TestModel.simpleMultiLevel();
+
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
+ while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the delta
+ fListener.reset();
+ // TODO Investigate: there seem to be unnecessary updates being issued
+ // by the viewer. These include the updates that are commented out:
+ // For now disable checking for extra updates.
+ fListener.setFailOnRedundantUpdates(false);
+ TestElement element = model.getRootElement();
+ TreePath path_root = TreePath.EMPTY;
+ ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta deltaRoot = delta;
+ element = element.getChildren()[2];
+ TreePath path_root_3 = path_root.createChildPath(element);
+ delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
+
+ // Validate the expansion state BEFORE posting the delta.
+
+ ITreeModelContentProviderTarget contentProviderViewer = (ITreeModelContentProviderTarget)fViewer;
+ Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+
+ model.postDelta(deltaRoot);
+ while (true) {
+ if (fListener.isFinished(MODEL_CHANGED_COMPLETE)) {
+ if (fListener.isFinished(CONTENT_UPDATES_COMPLETE | LABEL_UPDATES_COMPLETE) ) {
+ break;
+ }
+ }
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ }
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Validate the expansion state AFTER posting the delta.
+ Assert.assertTrue(contentProviderViewer.getExpandedState(path_root_3));
+
+ // Verify selection
+ ISelection selection = fViewer.getSelection();
+ if (selection instanceof ITreeSelection) {
+ List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() );
+ Assert.assertTrue(selectionPathsList.contains(path_root_3));
+ } else {
+ Assert.fail("Not a tree selection");
+ }
+ }
+
public void testCompositeModelRefreshStruct() {
//TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
@@ -515,7 +572,7 @@ abstract public class DeltaTests extends TestCase {
fListener.setFailOnRedundantUpdates(false);
m3.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.ALL_UPDATES_COMPLETE | TestModelUpdatesListener.MODEL_CHANGED_COMPLETE))
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | MODEL_CHANGED_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
model.validateData(fViewer, TreePath.EMPTY);
@@ -541,7 +598,7 @@ abstract public class DeltaTests extends TestCase {
fListener.reset(parentPath, parentElement, 0, false, false);
//fListener.addChildreCountUpdate(parentPath);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
// Validate the viewer data.
@@ -554,7 +611,7 @@ abstract public class DeltaTests extends TestCase {
// Update the viewer
fListener.reset(parentPath, parentElement, 0, false, false);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
// Validate the viewer data.
@@ -567,7 +624,7 @@ abstract public class DeltaTests extends TestCase {
// Update the viewer
fListener.reset(parentPath, parentElement, 0, false, false);
model.postDelta(delta);
- while (!fListener.isFinished(TestModelUpdatesListener.MODEL_CHANGED_COMPLETE | TestModelUpdatesListener.CONTENT_COMPLETE))
+ while (!fListener.isFinished(MODEL_CHANGED_COMPLETE | CONTENT_COMPLETE))
if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
// Validate the viewer data.
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
index af922ef60..73b4cb027 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/ITestModelUpdatesListenerConstants.java
@@ -17,25 +17,28 @@ package org.eclipe.debug.tests.viewer.model;
*/
public interface ITestModelUpdatesListenerConstants {
- public static final int LABEL_UPDATES_COMPLETE = 0X00000001;
- public static final int CONTENT_UPDATES_COMPLETE = 0X00000002;
- public static final int LABEL_UPDATES = 0X00000004;
- public static final int LABEL_UPDATES_STARTED = 0X00040000;
- public static final int HAS_CHILDREN_UPDATES = 0X00000008;
+ public static final int LABEL_UPDATES_COMPLETE = 0X00000001;
+ public static final int CONTENT_UPDATES_COMPLETE = 0X00000002;
+ public static final int CONTENT_UPDATES_STARTED = 0X00020000;
+ public static final int LABEL_UPDATES = 0X00000004;
+ public static final int LABEL_UPDATES_STARTED = 0X00040000;
+ public static final int HAS_CHILDREN_UPDATES = 0X00000008;
public static final int HAS_CHILDREN_UPDATES_STARTED = 0X00080000;
- public static final int CHILD_COUNT_UPDATES = 0X00000010;
- public static final int CHILD_COUNT_UPDATES_STARTED = 0X00100000;
- public static final int CHILDREN_UPDATES = 0X00000020;
- public static final int CHILDREN_UPDATES_STARTED = 0X00200000;
- public static final int MODEL_CHANGED_COMPLETE = 0X00000040;
- public static final int MODEL_PROXIES_INSTALLED = 0X00000080;
- public static final int STATE_SAVE_COMPLETE = 0X00000100;
- public static final int STATE_RESTORE_COMPLETE = 0X00000200;
- public static final int STATE_UPDATES = 0X00000400;
- public static final int STATE_UPDATES_STARTED = 0X04000000;
+ public static final int CHILD_COUNT_UPDATES = 0X00000010;
+ public static final int CHILD_COUNT_UPDATES_STARTED = 0X00100000;
+ public static final int CHILDREN_UPDATES = 0X00000020;
+ public static final int CHILDREN_UPDATES_STARTED = 0X00200000;
+ public static final int MODEL_CHANGED_COMPLETE = 0X00000040;
+ public static final int MODEL_PROXIES_INSTALLED = 0X00000080;
+ public static final int STATE_SAVE_COMPLETE = 0X00000100;
+ public static final int STATE_SAVE_STARTED = 0X01000000;
+ public static final int STATE_RESTORE_COMPLETE = 0X00000200;
+ public static final int STATE_RESTORE_STARTED = 0X02000000;
+ public static final int STATE_UPDATES = 0X00000400;
+ public static final int STATE_UPDATES_STARTED = 0X04000000;
- public static final int VIEWER_UPDATES_RUNNING = 0X00001000;
- public static final int LABEL_UPDATES_RUNNING = 0X00002000;
+ public static final int VIEWER_UPDATES_RUNNING = 0X00001000;
+ public static final int LABEL_UPDATES_RUNNING = 0X00002000;
public static final int VIEWER_UPDATES_STARTED = HAS_CHILDREN_UPDATES_STARTED | CHILD_COUNT_UPDATES_STARTED | CHILDREN_UPDATES_STARTED;
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java
new file mode 100644
index 000000000..f3dcce096
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/JFaceViewerPopupTests.java
@@ -0,0 +1,32 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipe.debug.tests.viewer.model;
+
+import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.TreeModelViewer;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.6
+ */
+public class JFaceViewerPopupTests extends PopupTests {
+
+ public JFaceViewerPopupTests(String name) {
+ super(name);
+ }
+
+ protected ITreeModelViewer createViewer(Display display, Shell shell, int style) {
+ return new TreeModelViewer(fShell, SWT.VIRTUAL | style, new PresentationContext("TestViewer"));
+ }
+}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java
new file mode 100644
index 000000000..38848d05a
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/PopupTests.java
@@ -0,0 +1,245 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipe.debug.tests.viewer.model;
+
+import java.util.Arrays;
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+import junit.framework.Assert;
+import junit.framework.TestCase;
+
+import org.eclipe.debug.tests.viewer.model.TestModel.TestElement;
+import org.eclipse.debug.internal.ui.viewers.model.ITreeModelContentProviderTarget;
+import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.IModelDelta;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.ModelDelta;
+import org.eclipse.jface.viewers.ISelection;
+import org.eclipse.jface.viewers.ITreeSelection;
+import org.eclipse.jface.viewers.TreePath;
+import org.eclipse.jface.viewers.TreeSelection;
+import org.eclipse.swt.SWT;
+import org.eclipse.swt.layout.FillLayout;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+import org.eclipse.ui.PlatformUI;
+
+/**
+ * Tests to verify that the viewer property updates when created
+ * with the SWT.POPUP style.
+ *
+ * @since 3.6
+ */
+abstract public class PopupTests extends TestCase implements ITestModelUpdatesListenerConstants {
+ Display fDisplay;
+ Shell fShell;
+ ITreeModelViewer fViewer;
+ TestModelUpdatesListener fListener;
+
+ public PopupTests(String name) {
+ super(name);
+ }
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void setUp() throws Exception {
+ fDisplay = PlatformUI.getWorkbench().getDisplay();
+ fShell = new Shell(fDisplay/*, SWT.ON_TOP | SWT.SHELL_TRIM*/);
+ fShell.setMaximized(true);
+ fShell.setLayout(new FillLayout());
+
+ fViewer = createViewer(fDisplay, fShell, SWT.POP_UP);
+
+ fListener = new TestModelUpdatesListener(fViewer, false, false);
+
+ fShell.open ();
+ }
+
+ protected ITreeModelContentProviderTarget getCTargetViewer() {
+ return (ITreeModelContentProviderTarget)fViewer;
+ }
+
+
+ abstract protected ITreeModelViewer createViewer(Display display, Shell shell, int style);
+
+ /**
+ * @throws java.lang.Exception
+ */
+ protected void tearDown() throws Exception {
+ fListener.dispose();
+ fViewer.getPresentationContext().dispose();
+
+ // Close the shell and exit.
+ fShell.close();
+ while (!fShell.isDisposed()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ }
+
+ /**
+ * This test verifies that content updates are still being performed.
+ */
+ public void testRefreshStruct() {
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+
+ TestModel model = TestModel.simpleSingleLevel();
+ fViewer.setAutoExpandLevel(-1);
+
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
+ while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ model.validateData(fViewer, TreePath.EMPTY);
+
+ // Update the model
+ TestElement element = model.getRootElement().getChildren()[0];
+ TreePath elementPath = new TreePath(new Object[] { element });
+ TestElement[] newChildren = new TestElement[] {
+ new TestElement(model, "1.1 - new", new TestElement[0]),
+ new TestElement(model, "1.2 - new", new TestElement[0]),
+ new TestElement(model, "1.3 - new", new TestElement[0]),
+ };
+ ModelDelta delta = model.setElementChildren(elementPath, newChildren);
+
+ fListener.reset(elementPath, element, -1, true, false);
+ model.postDelta(delta);
+ while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ model.validateData(fViewer, TreePath.EMPTY);
+ }
+
+ /**
+ * This test verifies that expand and select updates are being ignored.
+ */
+ public void testExpandAndSelect() {
+ TestModel model = TestModel.simpleMultiLevel();
+
+ // Create the listener
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), 1, true, false);
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
+ while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Create the delta
+ fListener.reset();
+ // TODO Investigate: there seem to be unnecessary updates being issued
+ // by the viewer. These include the updates that are commented out:
+ // For now disable checking for extra updates.
+ fListener.setFailOnRedundantUpdates(false);
+ TestElement element = model.getRootElement();
+ TreePath path_root = TreePath.EMPTY;
+ ModelDelta delta= new ModelDelta(model.getRootElement(), -1, IModelDelta.EXPAND, element.getChildren().length);
+ ModelDelta deltaRoot = delta;
+ element = element.getChildren()[2];
+ TreePath path_root_3 = path_root.createChildPath(element);
+ delta.addNode(element, 2, IModelDelta.SELECT | IModelDelta.EXPAND, element.fChildren.length);
+
+ // Validate the expansion state BEFORE posting the delta.
+
+ ITreeModelContentProviderTarget contentProviderViewer = (ITreeModelContentProviderTarget)fViewer;
+ Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+
+ model.postDelta(deltaRoot);
+ while (true) {
+ if (fListener.isFinished(MODEL_CHANGED_COMPLETE)) {
+ if (fListener.isFinished(CONTENT_UPDATES_STARTED)) {
+ if (fListener.isFinished(CONTENT_UPDATES_COMPLETE)) {
+ break;
+ }
+ } else {
+ break;
+ }
+ }
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ }
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Validate the expansion state AFTER posting the delta.
+ Assert.assertFalse(contentProviderViewer.getExpandedState(path_root_3));
+
+ // Verify selection
+ ISelection selection = fViewer.getSelection();
+ if (selection instanceof ITreeSelection) {
+ List selectionPathsList = Arrays.asList( ((ITreeSelection)selection).getPaths() );
+ Assert.assertFalse(selectionPathsList.contains(path_root_3));
+ } else {
+ Assert.fail("Not a tree selection");
+ }
+ }
+
+
+
+ public void testPreserveExpandedOnSubTreeContent() {
+ //TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
+ TestModel model = TestModel.simpleMultiLevel();
+
+ // Expand all
+ fViewer.setAutoExpandLevel(-1);
+
+ // Create the listener,
+ fListener.reset(TreePath.EMPTY, model.getRootElement(), -1, true, false);
+
+ // Set the input into the view and update the view.
+ fViewer.setInput(model.getRootElement());
+ while (!fListener.isFinished()) if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+ model.validateData(fViewer, TreePath.EMPTY, true);
+
+ // Turn off auto-expansion
+ fViewer.setAutoExpandLevel(0);
+
+ // Set a selection in view
+ TreeSelection originalSelection = new TreeSelection(model.findElement("3.3.1"));
+ fViewer.setSelection(originalSelection);
+
+ // Update the model
+ model.addElementChild(model.findElement("3"), 0, new TestElement(model, "3.0 - new", new TestElement[0]));
+
+ // Create the delta for element "3" with content update.
+ TreePath elementPath = model.findElement("3");
+ ModelDelta rootDelta = new ModelDelta(model.getRootElement(), IModelDelta.NO_CHANGE);
+ ModelDelta elementDelta = model.getElementDelta(rootDelta, elementPath, true);
+ elementDelta.setFlags(IModelDelta.CONTENT);
+
+ // Note: Re-expanding nodes causes redundant updates.
+ fListener.reset(false, false);
+ fListener.addUpdates(getCTargetViewer(), elementPath, model.getElement(elementPath), -1, ALL_UPDATES_COMPLETE);
+
+ // Post the sub-tree update
+ model.postDelta(rootDelta);
+ while (!fListener.isFinished(ALL_UPDATES_COMPLETE | STATE_RESTORE_COMPLETE))
+ if (!fDisplay.readAndDispatch ()) fDisplay.sleep ();
+
+ // Validate data
+ model.validateData(fViewer, TreePath.EMPTY, true);
+ Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3")) == true);
+ // On windows, getExpandedState() may return true for an element with no children:
+ // Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.0 - new")) == false);
+ Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.1")) == true);
+ Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.2")) == true);
+ Assert.assertTrue(getCTargetViewer().getExpandedState(model.findElement("3.3")) == true);
+ Assert.assertTrue( areTreeSelectionsEqual(originalSelection, (ITreeSelection)fViewer.getSelection()) );
+ }
+
+ private boolean areTreeSelectionsEqual(ITreeSelection sel1, ITreeSelection sel2) {
+ Set sel1Set = new HashSet();
+ sel1Set.addAll( Arrays.asList(sel1.getPaths()) );
+
+ Set sel2Set = new HashSet();
+ sel2Set.addAll( Arrays.asList(sel2.getPaths()) );
+
+ return sel1Set.equals(sel2Set);
+ }
+
+
+}
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
index 8cf539497..e172326eb 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java
@@ -227,7 +227,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
public void update(ILabelUpdate[] updates) {
for (int i = 0; i < updates.length; i++) {
TestElement element = (TestElement)updates[i].getElement();
- updates[i].setLabel(element.fID, 0);
+ updates[i].setLabel(element.getLabel(), 0);
if (updates[i] instanceof ICheckUpdate &&
Boolean.TRUE.equals(updates[i].getPresentationContext().getProperty(ICheckUpdate.PROP_CHECK)))
{
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 fdca40864..468e7d1c3 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
@@ -63,10 +63,14 @@ public class TestModelUpdatesListener
private Set fLabelUpdatesCompleted = new HashSet();
private Set fProxyModels = new HashSet();
private Set fStateUpdates = new HashSet();
+ private boolean fViewerUpdatesStarted;
private boolean fViewerUpdatesComplete;
+ private boolean fLabelUpdatesStarted;
private boolean fLabelUpdatesComplete;
private boolean fModelChangedComplete;
+ private boolean fStateSaveStarted;
private boolean fStateSaveComplete;
+ private boolean fStateRestoreStarted;
private boolean fStateRestoreComplete;
private int fViewerUpdatesCounter;
private int fLabelUpdatesCounter;
@@ -149,9 +153,13 @@ public class TestModelUpdatesListener
fLabelUpdatesRunning.clear();
fLabelUpdatesCompleted.clear();
fProxyModels.clear();
+ fViewerUpdatesStarted = false;
fViewerUpdatesComplete = false;
+ fLabelUpdatesStarted = false;
fLabelUpdatesComplete = false;
+ fStateSaveStarted = false;
fStateSaveComplete = false;
+ fStateRestoreStarted = false;
fStateRestoreComplete = false;
fTimeoutTime = System.currentTimeMillis() + fTimeoutInterval;
resetModelChanged();
@@ -290,11 +298,14 @@ public class TestModelUpdatesListener
if (!fLabelUpdatesComplete) return false;
}
if ( (flags & LABEL_UPDATES_STARTED) != 0) {
- if (fLabelUpdatesRunning.isEmpty() && fLabelUpdatesCompleted.isEmpty()) return false;
+ if (!fLabelUpdatesStarted) return false;
}
if ( (flags & LABEL_UPDATES) != 0) {
if (!fLabelUpdates.isEmpty()) return false;
}
+ if ( (flags & CONTENT_UPDATES_STARTED) != 0) {
+ if (!fViewerUpdatesStarted) return false;
+ }
if ( (flags & CONTENT_UPDATES_COMPLETE) != 0) {
if (!fViewerUpdatesComplete) return false;
}
@@ -322,9 +333,15 @@ public class TestModelUpdatesListener
if ( (flags & STATE_SAVE_COMPLETE) != 0) {
if (!fStateSaveComplete) return false;
}
+ if ( (flags & STATE_SAVE_STARTED) != 0) {
+ if (!fStateSaveStarted) return false;
+ }
if ( (flags & STATE_RESTORE_COMPLETE) != 0) {
if (!fStateRestoreComplete) return false;
}
+ if ( (flags & STATE_RESTORE_STARTED) != 0) {
+ if (!fStateRestoreStarted) return false;
+ }
if ( (flags & MODEL_PROXIES_INSTALLED) != 0) {
if (fProxyModels.size() != 0) return false;
}
@@ -397,13 +414,13 @@ public class TestModelUpdatesListener
}
public void viewerUpdatesBegin() {
-
- }
-
- public void viewerUpdatesComplete() {
if (fFailOnMultipleModelUpdateSequences && fViewerUpdatesComplete) {
fMultipleModelUpdateSequencesObserved = true;
}
+ fViewerUpdatesStarted = true;
+ }
+
+ public void viewerUpdatesComplete() {
fViewerUpdatesComplete = true;
}
@@ -426,12 +443,13 @@ public class TestModelUpdatesListener
}
public void labelUpdatesBegin() {
- }
-
- public void labelUpdatesComplete() {
if (fFailOnMultipleLabelUpdateSequences && fLabelUpdatesComplete) {
fMultipleLabelUpdateSequencesObserved = true;
}
+ fLabelUpdatesStarted = true;
+ }
+
+ public void labelUpdatesComplete() {
fLabelUpdatesComplete = true;
}
@@ -448,6 +466,7 @@ public class TestModelUpdatesListener
}
public void stateRestoreUpdatesBegin(Object input) {
+ fStateRestoreStarted = true;
}
public void stateRestoreUpdatesComplete(Object input) {
@@ -455,6 +474,7 @@ public class TestModelUpdatesListener
}
public void stateSaveUpdatesBegin(Object input) {
+ fStateSaveStarted = true;
}
public void stateSaveUpdatesComplete(Object input) {
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java
new file mode 100644
index 000000000..71484d116
--- /dev/null
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/VirtualViewerPopupTests.java
@@ -0,0 +1,33 @@
+/*******************************************************************************
+ * Copyright (c) 2009 Wind River Systems 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:
+ * Wind River Systems - initial API and implementation
+ *******************************************************************************/
+package org.eclipe.debug.tests.viewer.model;
+
+import org.eclipse.debug.internal.ui.viewers.model.ITreeModelViewer;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.PresentationContext;
+import org.eclipse.debug.internal.ui.viewers.model.provisional.VirtualTreeModelViewer;
+import org.eclipse.swt.widgets.Display;
+import org.eclipse.swt.widgets.Shell;
+
+/**
+ * @since 3.6
+ */
+public class VirtualViewerPopupTests extends PopupTests {
+
+ public VirtualViewerPopupTests(String name) {
+ super(name);
+ }
+
+ protected ITreeModelViewer createViewer(Display display, Shell shell, int style) {
+ return new VirtualTreeModelViewer(fDisplay, style, new PresentationContext("TestViewer"));
+ }
+
+
+}

Back to the top