diff --git a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java index 5ae0e281e5a..d18a0d5b86f 100644 --- a/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java +++ b/tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java @@ -24,7 +24,9 @@ import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Deque; +import java.util.HashSet; import java.util.List; +import java.util.Set; import java.util.concurrent.TimeUnit; import java.util.function.Consumer; import java.util.function.IntFunction; @@ -1377,6 +1379,23 @@ public void test_updateAllChildrenLinearGrowth() { }); } +@Test +public void test_breadthFirstTraverseUnique() { + testTreeRegularAndVirtual(() -> { + int size = 1000; + TreeItem root = new TreeItem(tree, SWT.NONE); + buildWideTree(root, size - 1); + Set items = new HashSet<>(); + tree.setRedraw(false); + breadthFirstTraverse(root, item -> { + assertTrue(items.add(item)); + item.setText("" + items.size() ); + }); + tree.setRedraw(true); + assertEquals(size, items.size()); + }); +} + private double measureUpdateAllChildren(int totalChildCount) { TreeItem root = new TreeItem(tree, SWT.NONE); buildWideTree(root, totalChildCount - 1); @@ -1384,7 +1403,9 @@ private double measureUpdateAllChildren(int totalChildCount) { tree.setRedraw(false); try { String text = "" + System.currentTimeMillis(); - breadthFirstTraverse(root, item -> item.setText(text)); + breadthFirstTraverse(root, item -> { + item.setText(text); + }); } finally { tree.setRedraw(true); }