Bug 551570 - Two org.eclipse.ui.genericeditor.tests.ContextInfoTest
fails on Linux since I20190926-0625, part 2

Relaxed time constraints in the ContextInfoTest

Change-Id: If7ad1876f3206eadd9298fa45ca42761282f83f5
Signed-off-by: Andrey Loskutov <loskutov@gmx.de>
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ContextInfoTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ContextInfoTest.java
index cf97234..dd7ffbc 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ContextInfoTest.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/ContextInfoTest.java
@@ -34,6 +34,7 @@
 import org.eclipse.jface.text.source.SourceViewer;
 
 import org.eclipse.ui.genericeditor.tests.contributions.BarContentAssistProcessor;
+import org.eclipse.ui.tests.harness.util.UITestCase;
 
 import org.eclipse.ui.texteditor.ITextEditorActionConstants;
 import org.eclipse.ui.texteditor.TextOperationAction;
@@ -54,16 +55,18 @@
 		TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
 
 		editor.selectAndReveal(4, 0);
+		UITestCase.processEvents();
+		
 		action.update();
 		action.run();
-		waitAndDispatch(100);
 		this.completionShell= findNewShell(beforeShells);
 		assertEquals("idx= 0", getInfoText(this.completionShell));
 
 		editor.selectAndReveal(8, 0);
+		UITestCase.processEvents();
+		
 		action.update();
 		action.run();
-		waitAndDispatch(100);
 		this.completionShell= findNewShell(beforeShells);
 		assertEquals("idx= 1", getInfoText(this.completionShell));
 	}
@@ -77,15 +80,17 @@
 		TextOperationAction action = (TextOperationAction) editor.getAction(ITextEditorActionConstants.CONTENT_ASSIST_CONTEXT_INFORMATION);
 
 		editor.selectAndReveal(4, 0);
+		UITestCase.processEvents();
+		
 		action.update();
 		action.run();
-		waitAndDispatch(100);
 		this.completionShell= findNewShell(beforeShells);
 
 		editor.selectAndReveal(8, 0);
+		UITestCase.processEvents();
+		
 		action.update();
 		action.run();
-		waitAndDispatch(100);
 		this.completionShell= findNewShell(beforeShells);
 
 		editor.getAction(ITextEditorActionConstants.DELETE_LINE).run();
@@ -97,12 +102,22 @@
 
 
 	private Shell findNewShell(Set<Shell> beforeShells) {
+		waitAndDispatch(100);
+		Shell[] afterShells= findNewShells(beforeShells);
+		if(afterShells.length == 0) {
+			waitAndDispatch(1000);
+		}
+		afterShells= findNewShells(beforeShells);
+		assertEquals("No new shell found", 1, afterShells.length);
+		return afterShells[0];
+	}
+
+	private Shell[] findNewShells(Set<Shell> beforeShells) {
 		Shell[] afterShells = Arrays.stream(editor.getSite().getShell().getDisplay().getShells())
 				.filter(Shell::isVisible)
 				.filter(shell -> !beforeShells.contains(shell))
 				.toArray(Shell[]::new);
-		assertEquals("No new shell found", 1, afterShells.length);
-		return afterShells[0];
+		return afterShells;
 	}
 
 	private String getInfoText(final Shell shell) {