From f1e80c6ed36d2ea9ba484fd872126bd185280091 Mon Sep 17 00:00:00 2001 From: Philipp Wagner Date: Wed, 18 Nov 2026 19:34:58 +0100 Subject: [PATCH] Bound the setup wizard window tests and close through the window's X Written-by: DeepSeek V4 Pro Written-by: Claude Fable 5.2 --- .../compose/wizard/SetupWizardWindowTest.kt | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardWindowTest.kt b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardWindowTest.kt index dfa87fc9..6f93f3bb 100644 --- a/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardWindowTest.kt +++ b/app-desktop/src/test/kotlin/kst4contest/view/compose/wizard/SetupWizardWindowTest.kt @@ -29,28 +29,35 @@ class SetupWizardWindowTest { private val closer = Executors.newSingleThreadExecutor() /** Closes the dialog the way its X does, as soon as it is on screen. */ - private fun disposeOnceShowing(): Future<*> = + private fun closeOnceShowing(): Future<*> = closer.submit { awaitUntil(Duration.ofSeconds(10), "the wizard's dialog never appeared") { showingDialog() != null } - EventQueue.invokeLater { showingDialog()?.dispose() } + EventQueue.invokeLater { + val window = showingDialog() + window?.dispatchEvent(java.awt.event.WindowEvent(window, java.awt.event.WindowEvent.WINDOW_CLOSING)) + } } @Test fun closingTheWindowCountsAsLater() { assumeFalse(GraphicsEnvironment.isHeadless(), "needs a display") + val worker = Executors.newSingleThreadExecutor() try { - val closing = disposeOnceShowing() + val closing = closeOnceShowing() val prefs = prefs() + val call = worker.submit { SetupWizardWindow.show(SetupWizardState(prefs), prefs) } - val outcome = SetupWizardWindow.show(SetupWizardState(prefs), prefs) + // A dialog that never appears must fail the test, not hang it. + val outcome = call.get(20, TimeUnit.SECONDS) assertEquals(SetupWizardOutcome.LATER, outcome) assertEquals("", prefs.getStn_loginCallSign(), "closing the window wrote something") closing.get(1, TimeUnit.SECONDS) } finally { + worker.shutdownNow() closer.shutdownNow() } } @@ -61,7 +68,7 @@ class SetupWizardWindowTest { val worker = Executors.newSingleThreadExecutor() try { - val closing = disposeOnceShowing() + val closing = closeOnceShowing() val prefs = prefs() val call = worker.submit { EventQueue.invokeAndWait { SetupWizardWindow.show(SetupWizardState(prefs), prefs) }