Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLucas Bullen2018-07-26 15:08:43 -0400
committerLucas Bullen2018-07-26 15:16:09 -0400
commit194bf37ffdde3f45ece6d5199bb179a3ec546486 (patch)
treea4ceee47a00c890461a81d3bdf9742634c31c0eb
parentc57ecc40192949a008423009363558df39cf5452 (diff)
downloadeclipse.platform.text-194bf37ffdde3f45ece6d5199bb179a3ec546486.tar.gz
eclipse.platform.text-194bf37ffdde3f45ece6d5199bb179a3ec546486.tar.xz
eclipse.platform.text-194bf37ffdde3f45ece6d5199bb179a3ec546486.zip
Bug 537195 - [Generic Editor] Failing hover testI20180726-2000
- Clean before broken test - Proper wait condition for setting caret location - wait for events to be processed instead of guessing at 1 second Change-Id: I34f486e4097b06f8de4884abfaeb3d2eb172298d Signed-off-by: Lucas Bullen <lbullen@redhat.com>
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java21
1 files changed, 17 insertions, 4 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java
index 3f08862ab..eb97b3446 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java
@@ -29,6 +29,7 @@ import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
import org.eclipse.swt.widgets.Composite;
import org.eclipse.swt.widgets.Control;
+import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
import org.eclipse.swt.widgets.Label;
import org.eclipse.swt.widgets.Link;
@@ -80,13 +81,14 @@ public class HoverTest extends AbstratGenericEditorTest {
@Test
public void testEnabledWhenHover() throws Exception {
+ cleanFileAndEditor();
EnabledPropertyTester.setEnabled(true);
createAndOpenFile("enabledWhen.txt", "bar 'bar'");
Shell shell = getHoverShell(triggerCompletionAndRetrieveInformationControlManager());
assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL));
assertNull(findControl(shell, StyledText.class, WorldHoverProvider.LABEL));
- cleanFileAndEditor();
+ cleanFileAndEditor();
EnabledPropertyTester.setEnabled(false);
createAndOpenFile("enabledWhen.txt", "bar 'bar'");
shell = getHoverShell(triggerCompletionAndRetrieveInformationControlManager());
@@ -216,14 +218,16 @@ public class HoverTest extends AbstratGenericEditorTest {
}
private AbstractInformationControlManager triggerCompletionAndRetrieveInformationControlManager() {
- this.editor.selectAndReveal(2, 0);
+ final int caretLocation= 2;
+ this.editor.selectAndReveal(caretLocation, 0);
final StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class);
new DisplayHelper() {
@Override
protected boolean condition() {
- return editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == 2;
+ return editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == caretLocation;
}
}.waitForCondition(editorTextWidget.getDisplay(), 1000);
+ assertTrue(editorTextWidget.isFocusControl() && editorTextWidget.getSelection().x == caretLocation);
// sending event to trigger hover computation
editorTextWidget.getShell().forceActive();
editorTextWidget.getShell().setActive();
@@ -239,11 +243,20 @@ public class HoverTest extends AbstratGenericEditorTest {
editorTextWidget.getDisplay().setCursorLocation(editorTextWidget.toDisplay(hoverEvent.x, hoverEvent.y));
editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent);
// Events need to be processed for hover listener to work correctly
- DisplayHelper.sleep(editorTextWidget.getDisplay(), 1000);
+ processViewEvents(editorTextWidget.getDisplay());
// retrieving hover content
ITextViewer viewer = (ITextViewer)new Accessor(editor, AbstractTextEditor.class).invoke("getSourceViewer", new Object[0]);
AbstractInformationControlManager textHoverManager = (AbstractInformationControlManager)new Accessor(viewer, TextViewer.class).get("fTextHoverManager");
return textHoverManager;
}
+ private void processViewEvents(Display display) {
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ return !display.readAndDispatch();
+ }
+ }.waitForCondition(display, 3000);
+ }
+
}

Back to the top