Skip to content

Commit

Permalink
Fix failing in Eclipse 4.34 hover test (#1160)
Browse files Browse the repository at this point in the history
Fix failing in Eclipse 4.34 hover test
  • Loading branch information
BoykoAlex authored Dec 10, 2024
1 parent 6e57065 commit 2dea8df
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: Tests for language server bundle (Incubation)
Bundle-SymbolicName: org.eclipse.lsp4e.test;singleton:=true
Bundle-Version: 0.15.20.qualifier
Bundle-Version: 0.15.21.qualifier
Fragment-Host: org.eclipse.lsp4e
Bundle-Vendor: Eclipse LSP4E
Bundle-RequiredExecutionEnvironment: JavaSE-17
Expand Down
2 changes: 1 addition & 1 deletion org.eclipse.lsp4e.test/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</parent>
<artifactId>org.eclipse.lsp4e.test</artifactId>
<packaging>eclipse-test-plugin</packaging>
<version>0.15.20-SNAPSHOT</version>
<version>0.15.21-SNAPSHOT</version>

<properties>
<os-jvm-flags /> <!-- for the default case -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,10 @@
package org.eclipse.lsp4e.test.hover;

import static org.eclipse.lsp4e.test.utils.TestUtils.waitForAndAssertCondition;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.File;
import java.io.IOException;
Expand Down Expand Up @@ -44,11 +47,11 @@
import org.eclipse.swt.layout.RowLayout;
import org.eclipse.swt.widgets.Display;
import org.eclipse.swt.widgets.Shell;
import org.eclipse.ui.IEditorPart;
import org.eclipse.ui.PlatformUI;
import org.eclipse.ui.ide.IDE;
import org.junit.Assert;
import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test;

@SuppressWarnings("restriction")
Expand Down Expand Up @@ -154,7 +157,6 @@ public void testMultipleHovers() throws Exception {
assertNotEquals("Hover content found only once", -1, index);
}

@Ignore("The test does not work from Eclipse 2024-12 onwards because the command org.eclipse.ui.file.close is not enabled")
@Test
public void testIntroUrlLink() throws Exception {
final var hoverResponse = new Hover(
Expand All @@ -164,7 +166,11 @@ public void testIntroUrlLink() throws Exception {
MockLanguageServer.INSTANCE.setHover(hoverResponse);

IFile file = TestUtils.createUniqueTestFile(project, "HoverRange Other Text");
ITextViewer viewer = TestUtils.openTextViewer(file);
IEditorPart editorPart = TestUtils.openEditor(file);

waitForAndAssertCondition(5_000, () -> LSPEclipseUtils.getTextViewer(editorPart) != null);
ITextViewer viewer = LSPEclipseUtils.getTextViewer(editorPart);
assertEquals(UI.getActivePart(), editorPart);

String hoverContent = hover.getHoverInfo(viewer, new Region(0, 10));

Expand Down Expand Up @@ -196,13 +202,15 @@ public void testIntroUrlLink() throws Exception {
@Override
public void completed(ProgressEvent event) {
browser.removeProgressListener(this);
assertEquals(UI.getActivePart(), editorPart);
browser.execute("document.getElementsByTagName('a')[0].click()");
completed.set(true);
}
});

assertNotNull("Editor should be opened", viewer.getTextWidget());


UI.getActivePage().activate(editorPart);
browser.setText(hoverContent);

waitForAndAssertCondition("action didn't close editor", 10_000, browser.getDisplay(),
Expand Down

0 comments on commit 2dea8df

Please sign in to comment.