Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2016-10-11 04:01:06 -0400
committerMickael Istria2016-10-11 10:36:35 -0400
commit8cbe29285e04f0b0e23b0346e953a62f0a8ccd75 (patch)
tree78d3d5725adaf234bcaae0154b8269fe356dc4df /org.eclipse.ui.genericeditor.tests
parentd929f218362bd560d9a6e43bf62820b06a1dcf79 (diff)
downloadeclipse.platform.text-8cbe29285e04f0b0e23b0346e953a62f0a8ccd75.tar.gz
eclipse.platform.text-8cbe29285e04f0b0e23b0346e953a62f0a8ccd75.tar.xz
eclipse.platform.text-8cbe29285e04f0b0e23b0346e953a62f0a8ccd75.zip
Bug 503332 - Show pop-up for problems on text on Generic Editor
It's just a regular Hover extension with highest priority Change-Id: Ic01f765f6abae99a18dba5817e26a1a6e8d1cd7a 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.java39
1 files changed, 32 insertions, 7 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 37f4f1b09..86f5bae8e 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
@@ -27,6 +27,8 @@ import org.eclipse.swt.widgets.Control;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Event;
+import org.eclipse.core.resources.IMarker;
+
import org.eclipse.jface.text.AbstractHoverInformationControlManager;
import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.ITextViewer;
@@ -70,13 +72,30 @@ public class HoverTest {
@Test
public void testHover() throws Exception {
- this.editor.selectAndReveal(2, 0);
- // Events need to be processed for hover listener to work correctly
- long timeout = 1000;
- long start = System.currentTimeMillis();
- while (start + timeout > System.currentTimeMillis()) {
- Display.getDefault().readAndDispatch();
+ assertEquals("Alrighty!", getHoverData());
+ }
+
+ @Test
+ public void testProblemHover() throws Exception {
+ String problemMessage = "Huston...";
+ IMarker marker = null;
+ try {
+ marker = GenericEditorTestUtils.getFile().createMarker(IMarker.PROBLEM);
+ marker.setAttribute(IMarker.LINE_NUMBER, 1);
+ marker.setAttribute(IMarker.SEVERITY, IMarker.SEVERITY_ERROR);
+ marker.setAttribute(IMarker.CHAR_START, 0);
+ marker.setAttribute(IMarker.CHAR_END, 5);
+ marker.setAttribute(IMarker.MESSAGE, problemMessage);
+ assertEquals(problemMessage, getHoverData());
+ } finally {
+ if (marker != null) {
+ marker.delete();
+ }
}
+ }
+
+ private Object getHoverData() throws Exception {
+ this.editor.selectAndReveal(2, 0);
// sending event to trigger hover computation
StyledText editorTextWidget = (StyledText) this.editor.getAdapter(Control.class);
editorTextWidget.getShell().forceActive();
@@ -91,6 +110,12 @@ public class HoverTest {
hoverEvent.display = editorTextWidget.getDisplay();
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();
+ }
// retrieving hover content
Method getSourceViewerMethod= AbstractTextEditor.class.getDeclaredMethod("getSourceViewer");
getSourceViewerMethod.setAccessible(true);
@@ -102,7 +127,7 @@ public class HoverTest {
informationField.setAccessible(true);
Object hoverData = informationField.get(hover);
Thread.sleep(500); // hoverData populated asynchronously
- assertEquals("Alrighty!", hoverData);
+ return hoverData;
}
}

Back to the top