Skip to content

Commit bbf4ec6

Browse files
EcljpseB0Tjukzi
authored andcommitted
[test] add Test for expand of invisible TreeItem eclipse-platform#901
fails on GTK eclipse-platform/eclipse.platform.ui#1331 (comment)
1 parent 425f14e commit bbf4ec6

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

tests/org.eclipse.swt.tests/JUnit Tests/org/eclipse/swt/tests/junit/Test_org_eclipse_swt_widgets_Tree.java

+32
Original file line numberDiff line numberDiff line change
@@ -1190,4 +1190,36 @@ public void test_setItemCount_itemCount2() {
11901190
});
11911191
}
11921192

1193+
@Test
1194+
public void test_persistExpandStatusForInvisibleItems() throws InterruptedException {
1195+
tree.dispose();
1196+
tree = new Tree(shell, SWT.VIRTUAL);
1197+
setWidget(tree);
1198+
shell.setLayout(new FillLayout());
1199+
SwtTestUtil.openShell(shell);
1200+
int itemCount[] = new int[] {1};
1201+
List<TreeItem> dataRequests = new ArrayList<>();
1202+
tree.addListener(SWT.SetData, event -> {
1203+
TreeItem item = (TreeItem) event.item;
1204+
dataRequests.add(item);
1205+
item.setText("item"+itemCount[0]++);
1206+
item.setItemCount(1);
1207+
});
1208+
TreeItem item1 = new TreeItem(tree, SWT.NONE);
1209+
TreeItem item2 = item1.getItem(0);
1210+
TreeItem item3 = item2.getItem(0);
1211+
assertTrue(dataRequests.remove(item1));
1212+
assertTrue(dataRequests.remove(item2));
1213+
assertTrue(dataRequests.isEmpty());
1214+
item2.setExpanded(true);
1215+
assertTrue(dataRequests.isEmpty());
1216+
item1.setExpanded(true);
1217+
// Item 3 is now visible and should request data
1218+
SwtTestUtil.processEvents(10000, () -> !dataRequests.isEmpty());
1219+
assertFalse(dataRequests.isEmpty());
1220+
assertTrue(item1.getExpanded());
1221+
assertTrue(item2.getExpanded());
1222+
assertFalse(item3.getExpanded());
1223+
}
1224+
11931225
}

0 commit comments

Comments
 (0)