Skip to content

[test] add Test for expand of invisible TreeItem #901 #933

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1190,4 +1190,36 @@ public void test_setItemCount_itemCount2() {
});
}

@Test
public void test_persistExpandStatusForInvisibleItems() throws InterruptedException {
tree.dispose();
tree = new Tree(shell, SWT.VIRTUAL);
setWidget(tree);
shell.setLayout(new FillLayout());
SwtTestUtil.openShell(shell);
int itemCount[] = new int[] {1};
List<TreeItem> dataRequests = new ArrayList<>();
tree.addListener(SWT.SetData, event -> {
TreeItem item = (TreeItem) event.item;
dataRequests.add(item);
item.setText("item"+itemCount[0]++);
item.setItemCount(1);
});
TreeItem item1 = new TreeItem(tree, SWT.NONE);
TreeItem item2 = item1.getItem(0);
TreeItem item3 = item2.getItem(0);
assertTrue(dataRequests.remove(item1));
assertTrue(dataRequests.remove(item2));
assertTrue(dataRequests.isEmpty());
item2.setExpanded(true);
assertTrue(dataRequests.isEmpty());
item1.setExpanded(true);
// Item 3 is now visible and should request data
SwtTestUtil.processEvents(10000, () -> !dataRequests.isEmpty());
assertFalse(dataRequests.isEmpty());
assertTrue(item1.getExpanded());
assertTrue(item2.getExpanded());
assertFalse(item3.getExpanded());
}

}