Harden the setup wizard after the branch review

Written-by: Gemini 4 Hydrogen (Antigravity)
Written-by: Claude Fable 5.2
This commit is contained in:
Rsclub2_2 committed 2026-11-18 21:32:12 +01:00
1 parent f871f551f7
commit a8cfe94853
13 files changed
+248 -31

No files matched your search

@@ -1,5 +1,8 @@
package kst4contest.view;
import kst4contest.controller.ActiveOperatorProfile;
import kst4contest.model.OperatorProfile;
import kst4contest.model.OperatorProfileSelection;
import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.assertFalse;
@@ -20,4 +23,39 @@ class ApplicationRuntimeLauncherSetupWizardTest {
assertTrue(ApplicationRuntimeLauncher.consumeSetupWizardRequest());
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(), "the request must not stick");
}
@Test
void switchGuardAllowsOnlyOneSwitchAtATime() {
try {
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
assertFalse(ApplicationRuntimeLauncher.beginSwitch(),
"a second switch must be refused while one is in progress");
} finally {
ApplicationRuntimeLauncher.endSwitch();
}
try {
assertTrue(ApplicationRuntimeLauncher.beginSwitch(),
"ending the first switch must release the guard");
} finally {
ApplicationRuntimeLauncher.endSwitch();
}
}
@Test
void rerunSetupWizardWhileSwitchInProgressReturnsFalseAndClearsRequest() {
OperatorProfileSelection previous = ActiveOperatorProfile.get();
OperatorProfile profile = new OperatorProfile("wizard-guard-test", "Wizard Guard Test", false, false);
ActiveOperatorProfile.set(new OperatorProfileSelection(profile, "preferences.xml", "worked.db", false));
assertTrue(ApplicationRuntimeLauncher.beginSwitch());
try {
assertFalse(ApplicationRuntimeLauncher.rerunSetupWizard());
assertFalse(ApplicationRuntimeLauncher.consumeSetupWizardRequest(),
"a refused rerun must not leave a wizard request behind");
} finally {
ApplicationRuntimeLauncher.endSwitch();
ApplicationRuntimeLauncher.consumeSetupWizardRequest();
ActiveOperatorProfile.set(previous);
}
}
}