Skip to content

Commit cdbb93a

Browse files
Copilotvogella
andcommitted
Add wait conditions to all tests checking empty selection
Also add DisplayHelper.waitForCondition() to tests that check for empty selection to ensure the table is fully populated before the assertion. This prevents race conditions where the table hasn't been initialized yet. Co-authored-by: vogella <[email protected]>
1 parent d4e16a6 commit cdbb93a

File tree

1 file changed

+40
-0
lines changed

1 file changed

+40
-0
lines changed

tests/org.eclipse.ui.tests/Eclipse UI Tests/org/eclipse/ui/tests/dialogs/ResourceInitialSelectionTest.java

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ public void testSingleSelectionAndOneInitialNonExistingSelectionWithInitialPatte
126126
dialog.open();
127127
dialog.refresh();
128128

129+
Display display = PlatformUI.getWorkbench().getDisplay();
130+
// Wait for table to be populated (even if selection remains empty)
131+
DisplayHelper.waitForCondition(display, 3000, () -> {
132+
Table table = (Table) ((Composite) ((Composite) ((Composite) dialog.getShell().getChildren()[0])
133+
.getChildren()[0]).getChildren()[0]).getChildren()[3];
134+
return table.getItemCount() > 0;
135+
});
136+
129137
List<Object> selected = getSelectedItems(dialog);
130138

131139
assertTrue("No file should be selected by default", selected.isEmpty());
@@ -143,6 +151,14 @@ public void testSingleSelectionAndOneInitialSelectionWithoutInitialPattern() {
143151
dialog.open();
144152
dialog.refresh();
145153

154+
Display display = PlatformUI.getWorkbench().getDisplay();
155+
// Wait for table to be populated (even if selection remains empty)
156+
DisplayHelper.waitForCondition(display, 3000, () -> {
157+
Table table = (Table) ((Composite) ((Composite) ((Composite) dialog.getShell().getChildren()[0])
158+
.getChildren()[0]).getChildren()[0]).getChildren()[3];
159+
return table.getItemCount() > 0;
160+
});
161+
146162
List<Object> selected = getSelectedItems(dialog);
147163

148164
assertTrue("No file should be selected by default", selected.isEmpty());
@@ -162,6 +178,14 @@ public void testSingleSelectionAndOneFilteredSelection() {
162178
dialog.open();
163179
dialog.refresh();
164180

181+
Display display = PlatformUI.getWorkbench().getDisplay();
182+
// Wait for table to be populated (even if selection remains empty)
183+
DisplayHelper.waitForCondition(display, 3000, () -> {
184+
Table table = (Table) ((Composite) ((Composite) ((Composite) dialog.getShell().getChildren()[0])
185+
.getChildren()[0]).getChildren()[0]).getChildren()[3];
186+
return table.getItemCount() > 0;
187+
});
188+
165189
List<Object> selected = getSelectedItems(dialog);
166190

167191
assertTrue("No file should be selected by default", selected.isEmpty());
@@ -246,6 +270,14 @@ public void testMultiSelectionAndOneInitialSelectionWithoutInitialPattern() {
246270
dialog.open();
247271
dialog.refresh();
248272

273+
Display display = PlatformUI.getWorkbench().getDisplay();
274+
// Wait for table to be populated (even if selection remains empty)
275+
DisplayHelper.waitForCondition(display, 3000, () -> {
276+
Table table = (Table) ((Composite) ((Composite) ((Composite) dialog.getShell().getChildren()[0])
277+
.getChildren()[0]).getChildren()[0]).getChildren()[3];
278+
return table.getItemCount() > 0;
279+
});
280+
249281
List<Object> selected = getSelectedItems(dialog);
250282

251283
assertTrue("No file should be selected by default", selected.isEmpty());
@@ -265,6 +297,14 @@ public void testMultiSelectionAndTwoInitialNonExistingSelectionWithInitialPatter
265297
dialog.open();
266298
dialog.refresh();
267299

300+
Display display = PlatformUI.getWorkbench().getDisplay();
301+
// Wait for table to be populated (even if selection remains empty)
302+
DisplayHelper.waitForCondition(display, 3000, () -> {
303+
Table table = (Table) ((Composite) ((Composite) ((Composite) dialog.getShell().getChildren()[0])
304+
.getChildren()[0]).getChildren()[0]).getChildren()[3];
305+
return table.getItemCount() > 0;
306+
});
307+
268308
List<Object> selected = getSelectedItems(dialog);
269309

270310
assertTrue("No file should be selected by default", selected.isEmpty());

0 commit comments

Comments
 (0)