Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMickael Istria2017-09-08 06:04:32 -0400
committerMickael Istria2017-09-08 06:04:32 -0400
commitc40615d48f10a760873dd7857883fac588438d39 (patch)
treebfd0c610fa4c581a1cc6a778fe1118a536aa8040 /org.eclipse.ui.genericeditor.tests
parent55c3acdef4f74ecddae3e3f6c89fdb691c2c64ad (diff)
downloadeclipse.platform.text-c40615d48f10a760873dd7857883fac588438d39.tar.gz
eclipse.platform.text-c40615d48f10a760873dd7857883fac588438d39.tar.xz
eclipse.platform.text-c40615d48f10a760873dd7857883fac588438d39.zip
Revert "Bug 513321 - Aggregate mutliple hover sources"
Diffstat (limited to 'org.eclipse.ui.genericeditor.tests')
-rw-r--r--org.eclipse.ui.genericeditor.tests/plugin.xml22
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java41
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/HoverTest.java39
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/HelloHoverProvider.java38
-rw-r--r--org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java (renamed from org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/AlrightyHoverProvider.java)2
5 files changed, 22 insertions, 120 deletions
diff --git a/org.eclipse.ui.genericeditor.tests/plugin.xml b/org.eclipse.ui.genericeditor.tests/plugin.xml
index c7ce8e9b8..d2c3f4580 100644
--- a/org.eclipse.ui.genericeditor.tests/plugin.xml
+++ b/org.eclipse.ui.genericeditor.tests/plugin.xml
@@ -26,13 +26,9 @@
<extension
point="org.eclipse.ui.genericeditor.hoverProviders">
<hoverProvider
- class="org.eclipse.ui.genericeditor.tests.contributions.AlrightyHoverProvider"
+ class="org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider"
contentType="org.eclipse.ui.genericeditor.tests.content-type">
</hoverProvider>
- <hoverProvider
- class="org.eclipse.ui.genericeditor.tests.contributions.HelloHoverProvider"
- contentType="org.eclipse.ui.genericeditor.tests.specialized-content-type-bartxt">
- </hoverProvider>
</extension>
<extension
point="org.eclipse.ui.genericeditor.reconcilers">
@@ -40,11 +36,11 @@
class="org.eclipse.ui.genericeditor.tests.contributions.TheReconcilerFirst"
contentType="org.eclipse.core.runtime.text">
</reconciler>
- <reconciler
- class="org.eclipse.ui.genericeditor.tests.contributions.TheReconcilerSecond"
- contentType="org.eclipse.ui.genericeditor.tests.specialized-content-type-bartxt">
- </reconciler>
- </extension>
+ <reconciler
+ class="org.eclipse.ui.genericeditor.tests.contributions.TheReconcilerSecond"
+ contentType="org.eclipse.ui.genericeditor.tests.reconciled-content-type">
+ </reconciler>
+ </extension>
<extension
point="org.eclipse.ui.genericeditor.presentationReconcilers">
<presentationReconciler
@@ -84,10 +80,10 @@
priority="normal">
</content-type>
<content-type
- base-type="org.eclipse.ui.genericeditor.tests.content-type"
+ base-type="org.eclipse.core.runtime.text"
file-names="bar.txt"
- id="org.eclipse.ui.genericeditor.tests.specialized-content-type-bartxt"
- name="Specialized Generic Editor content-type for &apos;bar.txt&apos;"
+ id="org.eclipse.ui.genericeditor.tests.reconciled-content-type"
+ name="Generic Editor Reconciler Test content-type"
priority="normal">
</content-type>
</extension>
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java
index 2d31f0ad0..6d12a6f54 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/AbstratGenericEditorTest.java
@@ -17,8 +17,6 @@ import org.junit.Before;
import org.eclipse.swt.widgets.Display;
-import org.eclipse.core.runtime.NullProgressMonitor;
-
import org.eclipse.core.resources.IFile;
import org.eclipse.core.resources.IProject;
import org.eclipse.core.resources.ResourcesPlugin;
@@ -49,42 +47,17 @@ public class AbstratGenericEditorTest {
project = ResourcesPlugin.getWorkspace().getRoot().getProject(getClass().getName() + System.currentTimeMillis());
project.create(null);
project.open(null);
- createAndOpenFile("foo.txt", "bar 'bar'");
- }
-
- /**
- * Creates a new file in the project, opens it, and associate that file with the test state
- * @param name name of the file in the project
- * @param contents content of the file
- * @throws Exception ex
- * @since 1.1
- */
- protected void createAndOpenFile(String name, String contents) throws Exception {
- this.file = project.getFile(name);
- this.file.create(new ByteArrayInputStream(contents.getBytes()), true, null);
- this.editor = (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
+ file = project.getFile("foo.txt");
+ file.create(new ByteArrayInputStream("bar 'bar'".getBytes()), true, null);
+ editor = (ExtensionBasedTextEditor) PlatformUI.getWorkbench().getActiveWorkbenchWindow()
.getActivePage().openEditor(new FileEditorInput(this.file), "org.eclipse.ui.genericeditor.GenericEditor");
- }
-
- /**
- * Closes editor and delete file. Keeps project open.
- * @throws Exception ex
- * @since 1.1
- */
- protected void cleanFileAndEditor() throws Exception {
- if (editor != null) {
- editor.close(false);
- editor = null;
- }
- if (file != null) {
- file.delete(true, new NullProgressMonitor());
- file = null;
- }
- }
+ }
@After
public void tearDown() throws Exception {
- cleanFileAndEditor();
+ if (file != null) {
+ file.delete(true, null);
+ }
if (project != null) {
project.delete(true, null);
}
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 e234e340a..a92fea669 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
@@ -10,14 +10,13 @@
*******************************************************************************/
package org.eclipse.ui.genericeditor.tests;
+import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
import java.util.Collections;
-import java.util.Map;
import org.junit.Assume;
import org.junit.Before;
@@ -47,8 +46,7 @@ import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.TextViewer;
import org.eclipse.jface.text.tests.util.DisplayHelper;
-import org.eclipse.ui.genericeditor.tests.contributions.AlrightyHoverProvider;
-import org.eclipse.ui.genericeditor.tests.contributions.HelloHoverProvider;
+import org.eclipse.ui.genericeditor.tests.contributions.MagicHoverProvider;
import org.eclipse.ui.genericeditor.tests.contributions.MarkerResolutionGenerator;
import org.eclipse.ui.workbench.texteditor.tests.ScreenshotTest;
@@ -69,23 +67,9 @@ public class HoverTest extends AbstratGenericEditorTest {
}
@Test
- public void testSingleHover() throws Exception {
+ public void testHover() throws Exception {
Shell shell = getHoverShell(triggerCompletionAndRetrieveInformationControlManager());
- assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL));
- assertNull(findControl(shell, StyledText.class, HelloHoverProvider.LABEL));
- }
-
- /**
- * @throws Exception ex
- * @since 1.1
- */
- @Test
- public void testMultipleHover() throws Exception {
- cleanFileAndEditor();
- createAndOpenFile("bar.txt", "Hi");
- Shell shell = getHoverShell(triggerCompletionAndRetrieveInformationControlManager());
- assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL));
- assertNotNull(findControl(shell, StyledText.class, HelloHoverProvider.LABEL));
+ assertNotNull(findControl(shell, StyledText.class, MagicHoverProvider.LABEL));
}
@Test
@@ -101,17 +85,10 @@ public class HoverTest extends AbstratGenericEditorTest {
marker.setAttribute(IMarker.MESSAGE, problemMessage);
marker.setAttribute(MarkerResolutionGenerator.FIXME, true);
AbstractInformationControlManager manager = triggerCompletionAndRetrieveInformationControlManager();
- Object hoverData = getHoverData(manager);
- assertTrue(hoverData instanceof Map);
- assertTrue(((Map<?,?>)hoverData).containsValue(Collections.singletonList(marker)));
- assertTrue(((Map<?,?>)hoverData).containsValue(AlrightyHoverProvider.LABEL));
- assertFalse(((Map<?,?>)hoverData).containsValue(HelloHoverProvider.LABEL));
+ assertEquals(Collections.singletonList(marker), getHoverData(manager));
// check dialog content
Shell shell= getHoverShell(manager);
assertNotNull(findControl(shell, Label.class, marker.getAttribute(IMarker.MESSAGE, "NONE")));
- assertNotNull(findControl(shell, StyledText.class, AlrightyHoverProvider.LABEL));
- assertNull(findControl(shell, StyledText.class, HelloHoverProvider.LABEL));
- // check quick-fix works
Link link = findControl(shell, Link.class, MarkerResolutionGenerator.FIXME);
assertNotNull(link);
Event event = new Event();
@@ -149,12 +126,6 @@ public class HoverTest extends AbstratGenericEditorTest {
fail();
}
Shell shell = (Shell)new Accessor(control[0], AbstractInformationControl.class).get("fShell");
- new DisplayHelper() {
- @Override
- protected boolean condition() {
- return shell.isVisible();
- }
- }.waitForCondition(this.editor.getSite().getShell().getDisplay(), 2000);
assertTrue(shell.isVisible());
return shell;
}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/HelloHoverProvider.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/HelloHoverProvider.java
deleted file mode 100644
index 12f53196e..000000000
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/HelloHoverProvider.java
+++ /dev/null
@@ -1,38 +0,0 @@
-/*******************************************************************************
- * Copyright (c) 2017 Red Hat Inc. and others
- * All rights reserved. This program and the accompanying materials
- * are made available under the terms of the Eclipse Public License v1.0
- * which accompanies this distribution, and is available at
- * http://www.eclipse.org/legal/epl-v10.html
- *
- * Contributors:
- * Mickael Istria (Red Hat Inc.)
- *******************************************************************************/
-package org.eclipse.ui.genericeditor.tests.contributions;
-
-import org.eclipse.jface.text.IRegion;
-import org.eclipse.jface.text.ITextHover;
-import org.eclipse.jface.text.ITextHoverExtension2;
-import org.eclipse.jface.text.ITextViewer;
-import org.eclipse.jface.text.Region;
-
-public class HelloHoverProvider implements ITextHover, ITextHoverExtension2 {
-
- public static final String LABEL= "Hello!";
-
- @Deprecated
- @Override
- public String getHoverInfo(ITextViewer textViewer, IRegion hoverRegion) {
- return null;
- }
-
- @Override
- public IRegion getHoverRegion(ITextViewer textViewer, int offset) {
- return new Region(0, textViewer.getTextWidget().getText().length());
- }
-
- @Override
- public Object getHoverInfo2(ITextViewer textViewer, IRegion hoverRegion) {
- return LABEL;
- }
-}
diff --git a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/AlrightyHoverProvider.java b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java
index 726036e6d..0bba76cf9 100644
--- a/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/AlrightyHoverProvider.java
+++ b/org.eclipse.ui.genericeditor.tests/src/org/eclipse/ui/genericeditor/tests/contributions/MagicHoverProvider.java
@@ -16,7 +16,7 @@ import org.eclipse.jface.text.ITextHoverExtension2;
import org.eclipse.jface.text.ITextViewer;
import org.eclipse.jface.text.Region;
-public class AlrightyHoverProvider implements ITextHover,ITextHoverExtension2 {
+public class MagicHoverProvider implements ITextHover,ITextHoverExtension2 {
public static final String LABEL= "Alrighty!";

Back to the top