Skip to content

Commit

Permalink
Test that traversal goes over unique TreeItems eclipse-platform#822
Browse files Browse the repository at this point in the history
  • Loading branch information
basilevs committed Nov 19, 2023
1 parent 6376da1 commit c021b99
Showing 1 changed file with 22 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -1377,14 +1379,33 @@ 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<TreeItem> 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);
return measureNanos(() -> {
tree.setRedraw(false);
try {
String text = "" + System.currentTimeMillis();
breadthFirstTraverse(root, item -> item.setText(text));
breadthFirstTraverse(root, item -> {
item.setText(text);
});
} finally {
tree.setRedraw(true);
}
Expand Down

0 comments on commit c021b99

Please sign in to comment.