@@ -82,6 +82,9 @@ public void testSingleSelectionAndNoInitialSelectionWithInitialPattern() {
8282 dialog .open ();
8383 dialog .refresh ();
8484
85+ Display display = PlatformUI .getWorkbench ().getDisplay ();
86+ DisplayHelper .waitForCondition (display , 3000 , () -> !getSelectedItems (dialog ).isEmpty ());
87+
8588 List <Object > selected = getSelectedItems (dialog );
8689
8790 assertFalse ("One file should be selected by default" , selected .isEmpty ());
@@ -100,6 +103,10 @@ public void testSingleSelectionAndOneInitialSelectionWithInitialPattern() {
100103 dialog .open ();
101104 dialog .refresh ();
102105
106+ Display display = PlatformUI .getWorkbench ().getDisplay ();
107+ DisplayHelper .waitForCondition (display , 3000 ,
108+ () -> asList (FILES .get ("foo.txt" )).equals (getSelectedItems (dialog )));
109+
103110 List <Object > selected = getSelectedItems (dialog );
104111
105112 assertEquals ("One file should be selected by default" , asList (FILES .get ("foo.txt" )), selected );
@@ -174,6 +181,10 @@ public void testSingleSelectionAndTwoInitialSelectionsWithInitialPattern() {
174181 dialog .open ();
175182 dialog .refresh ();
176183
184+ Display display = PlatformUI .getWorkbench ().getDisplay ();
185+ DisplayHelper .waitForCondition (display , 3000 ,
186+ () -> asList (FILES .get ("foo.txt" )).equals (getSelectedItems (dialog )));
187+
177188 List <Object > selected = getSelectedItems (dialog );
178189
179190 assertEquals ("The first file should be selected by default" , asList (FILES .get ("foo.txt" )), selected );
@@ -192,6 +203,9 @@ public void testMultiSelectionAndNoInitialSelectionWithInitialPattern() {
192203 dialog .open ();
193204 dialog .refresh ();
194205
206+ Display display = PlatformUI .getWorkbench ().getDisplay ();
207+ DisplayHelper .waitForCondition (display , 3000 , () -> !getSelectedItems (dialog ).isEmpty ());
208+
195209 List <Object > selected = getSelectedItems (dialog );
196210
197211 assertFalse ("One file should be selected by default" , selected .isEmpty ());
@@ -211,6 +225,10 @@ public void testMultiSelectionAndOneInitialSelectionWithInitialPattern() {
211225 dialog .open ();
212226 dialog .refresh ();
213227
228+ Display display = PlatformUI .getWorkbench ().getDisplay ();
229+ DisplayHelper .waitForCondition (display , 3000 ,
230+ () -> asList (FILES .get ("foo.txt" )).equals (getSelectedItems (dialog )));
231+
214232 List <Object > selected = getSelectedItems (dialog );
215233
216234 assertEquals ("One file should be selected by default" , asList (FILES .get ("foo.txt" )), selected );
@@ -266,8 +284,12 @@ public void testMultiSelectionAndSomeInitialNonExistingSelectionWithInitialPatte
266284 dialog .open ();
267285 dialog .refresh ();
268286
269- List < Object > selected = getSelectedItems ( dialog );
287+ Display display = PlatformUI . getWorkbench (). getDisplay ( );
270288 Set <IFile > expectedSelection = new HashSet <>(asList (FILES .get ("bar.txt" ), FILES .get ("foofoo" )));
289+ DisplayHelper .waitForCondition (display , 3000 ,
290+ () -> expectedSelection .equals (new HashSet <>(getSelectedItems (dialog ))));
291+
292+ List <Object > selected = getSelectedItems (dialog );
271293 boolean allInitialElementsAreSelected = expectedSelection .equals (new HashSet <>(selected ));
272294
273295 assertTrue ("Two files should be selected by default" , allInitialElementsAreSelected );
@@ -288,6 +310,12 @@ public void testMultiSelectionAndTwoInitialSelectionsWithInitialPattern() {
288310 dialog .open ();
289311 dialog .refresh ();
290312
313+ Display display = PlatformUI .getWorkbench ().getDisplay ();
314+ DisplayHelper .waitForCondition (display , 3000 , () -> {
315+ List <Object > selected = getSelectedItems (dialog );
316+ return selected .containsAll (initialSelection ) && initialSelection .containsAll (selected );
317+ });
318+
291319 List <Object > selected = getSelectedItems (dialog );
292320 boolean initialElementsAreSelected = selected .containsAll (initialSelection )
293321 && initialSelection .containsAll (selected );
@@ -310,8 +338,14 @@ public void testMultiSelectionAndTwoInitialFilteredSelections() {
310338 dialog .open ();
311339 dialog .refresh ();
312340
313- List < Object > selected = getSelectedItems ( dialog );
341+ Display display = PlatformUI . getWorkbench (). getDisplay ( );
314342 List <IFile > expectedSelection = asList (FILES .get ("foo.txt" ), FILES .get ("bar.txt" ));
343+ DisplayHelper .waitForCondition (display , 3000 , () -> {
344+ List <Object > selected = getSelectedItems (dialog );
345+ return selected .containsAll (expectedSelection ) && expectedSelection .containsAll (selected );
346+ });
347+
348+ List <Object > selected = getSelectedItems (dialog );
315349 boolean initialElementsAreSelected = selected .containsAll (expectedSelection )
316350 && expectedSelection .containsAll (selected );
317351
0 commit comments