Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPawel Piech2012-08-09 22:20:45 +0000
committerPawel Piech2012-08-09 22:20:45 +0000
commit96c56ca6cf72618cf338508794a130f7871e84ec (patch)
treea838807214097bcc793eae3fc854f0882851ef56
parent82d29ef16cd358343a9211389a14cc86c18b3521 (diff)
downloadeclipse.platform.debug-96c56ca6cf72618cf338508794a130f7871e84ec.tar.gz
eclipse.platform.debug-96c56ca6cf72618cf338508794a130f7871e84ec.tar.xz
eclipse.platform.debug-96c56ca6cf72618cf338508794a130f7871e84ec.zip
Bug 382046 - [flex] Intermittent failure in StateTests.testSaveAndRestoreInputInstance()v20120809-222045
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java5
-rw-r--r--org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/TestModel.java107
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java1
-rw-r--r--org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java18
4 files changed, 76 insertions, 55 deletions
diff --git a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java
index fad2d693d..3f63ba195 100644
--- a/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java
+++ b/org.eclipse.debug.tests/src/org/eclipe/debug/tests/viewer/model/StateTests.java
@@ -1104,6 +1104,7 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi
public void testSaveRestoreOrder() throws InterruptedException {
//TreeModelViewerAutopopulateAgent autopopulateAgent = new TreeModelViewerAutopopulateAgent(fViewer);
TestModel model = TestModel.simpleMultiLevel();
+ model.setDelayUpdates(true);
// Expand all
fViewer.setAutoExpandLevel(-1);
@@ -1123,7 +1124,9 @@ abstract public class StateTests extends TestCase implements ITestModelUpdatesLi
fListener.reset();
fListener.expectRestoreAfterSaveComplete();
fViewer.setInput(copyModel.getRootElement());
- while (!fListener.isFinished(STATE_RESTORE_STARTED)) Thread.sleep(0);
+ while (!fListener.isFinished(STATE_RESTORE_STARTED)) {
+ if (!fDisplay.readAndDispatch ()) Thread.sleep(0);
+ }
Assert.assertTrue("RESTORE started before SAVE to complete", fListener.isFinished(STATE_SAVE_COMPLETE));
}
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 6a3fca61b..4bed630bd 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
@@ -42,6 +42,7 @@ import org.eclipse.debug.internal.ui.viewers.provisional.AbstractModelProxy;
import org.eclipse.jface.viewers.TreePath;
import org.eclipse.jface.viewers.Viewer;
import org.eclipse.jface.viewers.ViewerFilter;
+import org.eclipse.swt.widgets.Display;
/**
* Test model for the use in unit tests. This test model contains a set of
@@ -163,6 +164,7 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
private ModelProxy fModelProxy;
private IModelSelectionPolicy fModelSelectionPolicy;
private boolean fQueueingUpdates = false;
+ private boolean fDelayUpdates = false;
private List fQueuedUpdates = new LinkedList();
/**
@@ -218,7 +220,11 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
processQueuedUpdates();
}
}
-
+
+ public void setDelayUpdates(boolean delayUpdates) {
+ fDelayUpdates = delayUpdates;
+ }
+
public List getQueuedUpdates() {
return fQueuedUpdates;
}
@@ -233,59 +239,66 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
public void processUpdate(IViewerUpdate update) {
if (update instanceof IHasChildrenUpdate) {
- doUpdate((IHasChildrenUpdate)update);
+ doHasChildrenUpdate((IHasChildrenUpdate)update);
} else if (update instanceof IChildrenCountUpdate) {
- doUpdate((IChildrenCountUpdate)update);
+ doChildrenCountUpdate((IChildrenCountUpdate)update);
} else if (update instanceof IChildrenUpdate) {
- doUpdate((IChildrenUpdate)update);
+ doChildrenUpdate((IChildrenUpdate)update);
} else if (update instanceof ILabelUpdate) {
- doUpdate((ILabelUpdate)update);
- }
+ doLabelUpdate((ILabelUpdate)update);
+ } else if (update instanceof IElementCompareRequest) {
+ doCompareElements((IElementCompareRequest)update);
+ } else if (update instanceof IElementMementoRequest) {
+ doEncodeElements((IElementMementoRequest)update);
+ }
+ }
+
+ private void processUpdates(IViewerUpdate[] updates) {
+ for (int i = 0; i < updates.length; i++) {
+ processUpdate(updates[i]);
+ }
}
- public void update(IHasChildrenUpdate[] updates) {
+ private void doUpdate(final IViewerUpdate[] updates) {
if (fQueueingUpdates) {
fQueuedUpdates.addAll(Arrays.asList(updates));
+ } else if (fDelayUpdates) {
+ Display.getDefault().asyncExec(new Runnable() {
+ public void run() {
+ processUpdates(updates);
+ }
+ });
} else {
- for (int i = 0; i < updates.length; i++) {
- doUpdate(updates[i]);
- }
- }
+ processUpdates(updates);
+ }
+ }
+
+ public void update(IHasChildrenUpdate[] updates) {
+ doUpdate(updates);
}
- private void doUpdate(IHasChildrenUpdate update) {
+ private void doHasChildrenUpdate(IHasChildrenUpdate update) {
TestElement element = (TestElement)update.getElement();
update.setHasChilren(element.getChildren().length > 0);
update.done();
}
+
public void update(IChildrenCountUpdate[] updates) {
- if (fQueueingUpdates) {
- fQueuedUpdates.addAll(Arrays.asList(updates));
- } else {
- for (int i = 0; i < updates.length; i++) {
- doUpdate(updates[i]);
- }
- }
+ doUpdate(updates);
}
- private void doUpdate(IChildrenCountUpdate update) {
+ private void doChildrenCountUpdate(IChildrenCountUpdate update) {
TestElement element = (TestElement)update.getElement();
update.setChildCount(element.getChildren().length);
update.done();
}
public void update(IChildrenUpdate[] updates) {
- if (fQueueingUpdates) {
- fQueuedUpdates.addAll(Arrays.asList(updates));
- } else {
- for (int i = 0; i < updates.length; i++) {
- doUpdate(updates[i]);
- }
- }
+ doUpdate(updates);
}
- private void doUpdate(IChildrenUpdate update) {
+ private void doChildrenUpdate(IChildrenUpdate update) {
TestElement element = (TestElement)update.getElement();
int endOffset = update.getOffset() + update.getLength();
for (int j = update.getOffset(); j < endOffset; j++) {
@@ -297,16 +310,10 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
}
public void update(ILabelUpdate[] updates) {
- if (fQueueingUpdates) {
- fQueuedUpdates.addAll(Arrays.asList(updates));
- } else {
- for (int i = 0; i < updates.length; i++) {
- doUpdate(updates[i]);
- }
- }
+ doUpdate(updates);
}
- private void doUpdate(ILabelUpdate update) {
+ private void doLabelUpdate(ILabelUpdate update) {
TestElement element = (TestElement)update.getElement();
update.setLabel(element.getLabel(), 0);
if (update instanceof ICheckUpdate &&
@@ -319,24 +326,26 @@ public class TestModel implements IElementContentProvider, IElementLabelProvider
public final static String ELEMENT_MEMENTO_ID = "id";
- public void compareElements(IElementCompareRequest[] updates) {
- for (int i = 0; i < updates.length; i++) {
- String elementID = ((TestElement)updates[i].getElement()).getID();
- String mementoID = updates[i].getMemento().getString(ELEMENT_MEMENTO_ID);
- updates[i].setEqual( elementID.equals(mementoID) );
- updates[i].done();
- }
-
+ public void compareElements(final IElementCompareRequest[] updates) {
+ doUpdate(updates);
+ }
+
+ private void doCompareElements(IElementCompareRequest update) {
+ String elementID = ((TestElement)update.getElement()).getID();
+ String mementoID = update.getMemento().getString(ELEMENT_MEMENTO_ID);
+ update.setEqual( elementID.equals(mementoID) );
+ update.done();
}
public void encodeElements(IElementMementoRequest[] updates) {
- for (int i = 0; i < updates.length; i++) {
- String elementID = ((TestElement)updates[i].getElement()).getID();
- updates[i].getMemento().putString(ELEMENT_MEMENTO_ID, elementID);
- updates[i].done();
- }
+ doUpdate(updates);
}
+ private void doEncodeElements(IElementMementoRequest update) {
+ String elementID = ((TestElement)update.getElement()).getID();
+ update.getMemento().putString(ELEMENT_MEMENTO_ID, elementID);
+ update.done();
+ }
/**
* @param context the context
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
index cdfecec33..b4d8a6554 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/InternalVirtualTreeModelViewer.java
@@ -219,6 +219,7 @@ public class InternalVirtualTreeModelViewer extends Viewer
Object oldInput = fInput;
getContentProvider().inputChanged(this, oldInput, input);
fItemsMap.clear();
+ fTree.clearAll();
fInput = input;
mapElement(fInput, getTree());
getContentProvider().postInputChanged(this, oldInput , input);
diff --git a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java
index 9842d49d3..764d50272 100644
--- a/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java
+++ b/org.eclipse.debug.ui/ui/org/eclipse/debug/internal/ui/viewers/model/provisional/VirtualItem.java
@@ -160,6 +160,18 @@ public class VirtualItem {
}
/**
+ * Clears all child items.
+ *
+ * @since 3.9
+ */
+ public void clearAll() {
+ fData.clear();
+ for (Iterator itr = fItems.values().iterator(); itr.hasNext();) {
+ ((VirtualItem)itr.next()).dispose();
+ }
+ fItems.clear();
+ }
+ /**
* Returns the parent item.
* @return parent item.
*/
@@ -265,11 +277,7 @@ public class VirtualItem {
* Disposes the item.
*/
public void dispose() {
- fData.clear();
- for (Iterator itr = fItems.values().iterator(); itr.hasNext();) {
- ((VirtualItem)itr.next()).dispose();
- }
- fItems.clear();
+ clearAll();
fDisposed = true;
findTree().fireItemDisposed(this);

Back to the top