Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,13 @@ public static void waitForFocus(Supplier<Boolean> hasFocusValidator, String test
}
if (!hasFocusValidator.get()) {
String screenshotPath= ScreenshotTest.takeScreenshot(FindReplaceUITest.class, testName, System.out);
fail("The find/replace UI did not receive focus. Screenshot: " + screenshotPath);
Display display= PlatformUI.getWorkbench().getDisplay();
// Where the focus ended up instead tells apart the usual causes: no focus
// control at all means the window is not active, a control of the workbench
// means something took the focus away, and an invisible widget tree means the
// focus was never given away in the first place.
fail("The find/replace UI did not receive focus. Focused control: " + display.getFocusControl()
+ ", active shell: " + display.getActiveShell() + ". Screenshot: " + screenshotPath);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import java.util.ResourceBundle;

import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.TestInfo;
Expand Down Expand Up @@ -84,7 +85,6 @@ public class FindReplaceOverlayInEditorTest {
void openEditorWithOverlay(TestInfo testInfo) throws PartInitException {
testName = testInfo.getTestMethod().get().getName();
PlatformUI.getWorkbench().getWorkbenchWindows()[0].getShell().forceActive();
closeWelcomePage();
IWorkbenchPage page = PlatformUI.getWorkbench().getActiveWorkbenchWindow().getActivePage();
editor = (StatusTextEditor) page.openEditor(new TestTextEditorInput(CONTENT), TestTextEditor.ID);
runEventQueue();
Expand All @@ -103,11 +103,23 @@ void openEditorWithOverlay(TestInfo testInfo) throws PartInitException {
* bundle's own dependencies, the workbench opens its Welcome page over the whole
* window on a fresh workspace. It would cover the editor and keep the focus, so
* that the overlay never receives it. Nothing to close where no such page exists.
* <p>
* The page is put into standby before it is closed, because it is shown
* maximized: closing it right away leaves the window maximized on a part that is
* gone, and an editor opened afterwards is then never rendered into the window.
* It remains in the rendering engine's limbo instead, where it is invisible, and
* nothing inside an invisible widget tree can take the focus, so the overlay
* would never receive it. Standby restores the window's regular layout.
* <p>
* Closing once for the whole class is enough, since the page does not come back.
*/
private static void closeWelcomePage() {
@BeforeAll
static void closeWelcomePage() {
IIntroManager introManager = PlatformUI.getWorkbench().getIntroManager();
IIntroPart welcomePage = introManager.getIntro();
if (welcomePage != null) {
introManager.setIntroStandby(welcomePage, true);
runEventQueue();
introManager.closeIntro(welcomePage);
runEventQueue();
}
Expand Down
Loading