diff options
| author | Paul Buetow <paul@buetow.org> | 2026-03-27 16:13:02 +0200 |
|---|---|---|
| committer | Paul Buetow <paul@buetow.org> | 2026-03-27 16:13:02 +0200 |
| commit | 724e56b83bfa65cd2e870c54de1d83eec012f165 (patch) | |
| tree | bf498b78e7b7be68ccbecf8e782a768a96155a42 /src/main/java | |
| parent | 0fdd21929ca93e787d6092fe3ad0d8181f1be4d7 (diff) | |
Test VSMain main startup entrypoint
Diffstat (limited to 'src/main/java')
| -rw-r--r-- | src/main/java/simulator/VSMain.java | 56 |
1 files changed, 46 insertions, 10 deletions
diff --git a/src/main/java/simulator/VSMain.java b/src/main/java/simulator/VSMain.java index 3332e85..b3ef317 100644 --- a/src/main/java/simulator/VSMain.java +++ b/src/main/java/simulator/VSMain.java @@ -20,10 +20,47 @@ import prefs.VSPrefs; * @author Paul C. Buetow */ public class VSMain { + interface SplashScreenLauncher { + void show(); + } + + interface StartupDelay { + void pause() throws InterruptedException; + } + interface SimulatorFrameFactory { VSSimulatorFrame create(VSPrefs prefs, Component relativeTo); } + private static final SplashScreenLauncher DEFAULT_SPLASH_LAUNCHER = + new SplashScreenLauncher() { + public void show() { + VSSplashScreen splash = new VSSplashScreen(); + splash.showSplash(); + } + }; + + private static final StartupDelay DEFAULT_STARTUP_DELAY = + new StartupDelay() { + public void pause() throws InterruptedException { + Thread.sleep(3000); + } + }; + + private static final SimulatorFrameFactory DEFAULT_FRAME_FACTORY = + new SimulatorFrameFactory() { + public VSSimulatorFrame create(VSPrefs prefs, + Component relativeTo) { + return new VSSimulatorFrame(prefs, relativeTo); + } + }; + + static volatile SplashScreenLauncher splashScreenLauncher = + DEFAULT_SPLASH_LAUNCHER; + static volatile StartupDelay startupDelay = DEFAULT_STARTUP_DELAY; + static volatile SimulatorFrameFactory simulatorFrameFactory = + DEFAULT_FRAME_FACTORY; + /** The global preferences */ public static VSPrefs prefs; @@ -77,12 +114,7 @@ public class VSMain { Component relativeTo, String startupSimulationFile) { return launchSimulatorFrame(prefs, relativeTo, startupSimulationFile, - new SimulatorFrameFactory() { - public VSSimulatorFrame create(VSPrefs framePrefs, - Component frameRelativeTo) { - return new VSSimulatorFrame(framePrefs, frameRelativeTo); - } - }); + simulatorFrameFactory); } static VSSimulatorFrame launchSimulatorFrame(VSPrefs prefs, @@ -128,15 +160,19 @@ public class VSMain { } } + static void resetTestHooks() { + splashScreenLauncher = DEFAULT_SPLASH_LAUNCHER; + startupDelay = DEFAULT_STARTUP_DELAY; + simulatorFrameFactory = DEFAULT_FRAME_FACTORY; + } + /** * The main method. * * @param args the arguments */ public static void main(String[] args) { - // Show splash screen - VSSplashScreen splash = new VSSplashScreen(); - splash.showSplash(); + splashScreenLauncher.show(); try { UIManager.setLookAndFeel( @@ -151,7 +187,7 @@ public class VSMain { // Wait for splash screen to finish before showing main window try { - Thread.sleep(3000); + startupDelay.pause(); } catch (InterruptedException e) { Thread.currentThread().interrupt(); } |
