Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Keller2017-03-08 12:27:39 -0500
committerMarkus Keller2017-03-08 12:27:39 -0500
commitdad356880b62128e58665dd3e641e51ab61e03c0 (patch)
treee12b8e459073947b0a6b22293a142b966501b994 /org.eclipse.ui.genericeditor.tests
parent5985a1edc5adad4a81892f9229e3269c8b25e794 (diff)
downloadeclipse.platform.text-dad356880b62128e58665dd3e641e51ab61e03c0.tar.gz
eclipse.platform.text-dad356880b62128e58665dd3e641e51ab61e03c0.tar.xz
eclipse.platform.text-dad356880b62128e58665dd3e641e51ab61e03c0.zip
Bug 511101: [Generic Editor] misses quick fix on error markers
- improved HoverTest (no endless loop, better logging) - removed dependency on platform.ui test bundle - improved ScreenshotTest
Diffstat (limited to 'org.eclipse.ui.genericeditor.tests')
-rw-r--r--org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF3
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java31
2 files changed, 25 insertions, 9 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF
index cf5e71944..123f4c261 100644
--- a/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF
+++ b/org.eclipse.ui.genericeditor.tests/META-INF/MANIFEST.MF
@@ -17,8 +17,9 @@ Require-Bundle: org.eclipse.core.runtime;bundle-version="[3.6.0,4.0.0)",
org.eclipse.ui;bundle-version="3.108.0",
org.eclipse.ui.workbench.texteditor;bundle-version="3.10.0",
org.eclipse.ui.ide;bundle-version="3.11.0",
+ org.eclipse.jface.text.tests;bundle-version="3.11.100",
org.eclipse.text.tests;bundle-version="3.11.0",
- org.eclipse.ui.tests.harness
+ org.eclipse.ui.workbench.texteditor.tests;bundle-version="3.11.100"
Bundle-RequiredExecutionEnvironment: JavaSE-1.8
Eclipse-BundleShape: dir
Bundle-ActivationPolicy: lazy
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 4a6a394b4..f130f4d23 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
@@ -14,6 +14,7 @@ import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
import java.util.Collections;
@@ -21,7 +22,9 @@ import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;
import org.junit.BeforeClass;
+import org.junit.Rule;
import org.junit.Test;
+import org.junit.rules.TestName;
import org.eclipse.swt.SWT;
import org.eclipse.swt.custom.StyledText;
@@ -41,12 +44,14 @@ import org.eclipse.jface.text.AbstractInformationControl;
import org.eclipse.jface.text.AbstractInformationControlManager;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextViewer;
+import org.eclipse.jface.text.tests.util.DisplayHelper;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider;
import org.eclipse.ui.genericeditor.tests.contributions.MarkerResolutionGenerator;
import org.eclipse.ui.part.FileEditorInput;
-import org.eclipse.ui.tests.harness.util.DisplayHelper;
+
+import org.eclipse.ui.workbench.texteditor.tests.ScreenshotTest;
import org.eclipse.ui.texteditor.AbstractTextEditor;
@@ -56,6 +61,9 @@ import org.eclipse.ui.texteditor.AbstractTextEditor;
*/
public class HoverTest {
+ @Rule
+ public TestName testName = new TestName();
+
private AbstractTextEditor editor;
@BeforeClass
@@ -121,12 +129,19 @@ public class HoverTest {
}
private Shell getHoverShell(AbstractInformationControlManager manager) {
- AbstractInformationControl control = null;
- do {
- DisplayHelper.runEventLoop(this.editor.getSite().getShell().getDisplay(), 100);
- control = (AbstractInformationControl)new Accessor(manager, AbstractInformationControlManager.class).get("fInformationControl");
- } while (control == null);
- Shell shell = (Shell)new Accessor(control, AbstractInformationControl.class).get("fShell");
+ AbstractInformationControl[] control = { null };
+ new DisplayHelper() {
+ @Override
+ protected boolean condition() {
+ control[0] = (AbstractInformationControl)new Accessor(manager, AbstractInformationControlManager.class).get("fInformationControl");
+ return control[0] != null;
+ }
+ }.waitForCondition(this.editor.getSite().getShell().getDisplay(), 5000);
+ if (control[0] == null) {
+ ScreenshotTest.takeScreenshot(getClass(), testName.getMethodName(), System.out);
+ fail();
+ }
+ Shell shell = (Shell)new Accessor(control[0], AbstractInformationControl.class).get("fShell");
assertTrue(shell.isVisible());
return shell;
}
@@ -190,7 +205,7 @@ public class HoverTest {
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.runEventLoop(editorTextWidget.getDisplay(), 1000);
+ DisplayHelper.sleep(editorTextWidget.getDisplay(), 1000);
// 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");

Back to the top