diff options
author | Mickael Istria | 2016-10-13 08:54:39 +0000 |
---|---|---|
committer | Mickael Istria | 2016-10-13 09:09:28 +0000 |
commit | 1a9d72873c8c8c2b74bc39442a3a66dc786a9cf2 (patch) | |
tree | ce0a499280a98fb181da4e9f074092b6fc76a506 /org.eclipse.ui.genericeditor.tests | |
parent | 8cbe29285e04f0b0e23b0346e953a62f0a8ccd75 (diff) | |
download | eclipse.platform.text-1a9d72873c8c8c2b74bc39442a3a66dc786a9cf2.tar.gz eclipse.platform.text-1a9d72873c8c8c2b74bc39442a3a66dc786a9cf2.tar.xz eclipse.platform.text-1a9d72873c8c8c2b74bc39442a3a66dc786a9cf2.zip |
Bug 505842 - [generic editor] Test failure in HoverTest.testHoverY20161013-1000
Add more pauses to let event process
Change-Id: I5005c4c8879cf07d2cad0ce11aa5057849ced55e
Signed-off-by: Mickael Istria <mistria@redhat.com>
Diffstat (limited to 'org.eclipse.ui.genericeditor.tests')
-rw-r--r-- | org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java | 17 |
1 files changed, 11 insertions, 6 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 86f5bae8e44..6d29a391f68 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 @@ -96,6 +96,7 @@ public class HoverTest { private Object getHoverData() throws Exception { this.editor.selectAndReveal(2, 0); + waitAndDispatch(); // sending event to trigger hover computation StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class); editorTextWidget.getShell().forceActive(); @@ -111,11 +112,7 @@ public class HoverTest { hoverEvent.doit = true; editorTextWidget.notifyListeners(SWT.MouseHover, hoverEvent); // Events need to be processed for hover listener to work correctly - long timeout = 1000; //ms - long start = System.currentTimeMillis(); - while (start + timeout > System.currentTimeMillis()) { - Display.getDefault().readAndDispatch(); - } + waitAndDispatch(); // retrieving hover content Method getSourceViewerMethod= AbstractTextEditor.class.getDeclaredMethod("getSourceViewer"); getSourceViewerMethod.setAccessible(true); @@ -126,8 +123,16 @@ public class HoverTest { Field informationField = AbstractInformationControlManager.class.getDeclaredField("fInformation"); informationField.setAccessible(true); Object hoverData = informationField.get(hover); - Thread.sleep(500); // hoverData populated asynchronously + waitAndDispatch(); return hoverData; } + private void waitAndDispatch() { + long timeout = 1000; //ms + long start = System.currentTimeMillis(); + while (start + timeout > System.currentTimeMillis()) { + Display.getDefault().readAndDispatch(); + } + } + } |