diff --git a/core/src/test/java/com/github/weisj/darklaf/core/test/DemoTest.java b/core/src/test/java/com/github/weisj/darklaf/core/test/DemoTest.java index a91c2cfa..abe3eea3 100644 --- a/core/src/test/java/com/github/weisj/darklaf/core/test/DemoTest.java +++ b/core/src/test/java/com/github/weisj/darklaf/core/test/DemoTest.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2019-2021 Jannis Weis + * Copyright (c) 2019-2022 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -53,7 +53,6 @@ class DemoTest implements NonThreadSafeTest { @Test void runningDemosDoesNotThrow() { - @SuppressWarnings("Convert2MethodRef") Robot robot = Lambdas.orDefault(() -> new Robot(), null).get(); LafManager.setLogLevel(Level.WARNING); for (Theme theme : LafManager.getRegisteredThemes()) { diff --git a/core/src/test/java/com/github/weisj/darklaf/ui/DemoLauncher.java b/core/src/test/java/com/github/weisj/darklaf/ui/DemoLauncher.java index 94bd1d4e..3d8c2c9e 100644 --- a/core/src/test/java/com/github/weisj/darklaf/ui/DemoLauncher.java +++ b/core/src/test/java/com/github/weisj/darklaf/ui/DemoLauncher.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2020-2021 Jannis Weis + * Copyright (c) 2020-2022 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -28,6 +28,7 @@ import java.util.stream.Collectors; import javax.swing.*; +import com.github.weisj.darklaf.LafManager; import com.github.weisj.darklaf.core.test.DarklafOnly; import com.github.weisj.darklaf.core.test.DelicateDemo; import com.github.weisj.darklaf.core.test.util.ClassFinder; @@ -90,14 +91,15 @@ public class DemoLauncher extends BaseComponentDemo { this.demo = demo; } - public AtomicReference start() { - return start(null).getFirst(); + public void start() { + start(null); } public Pair, ComponentDemo> start(final Level logLevel) { ComponentDemo componentDemo = demo.instantiate(); + LafManager.setLogLevel(logLevel != null ? logLevel : Level.FINE); return new Pair<>( - DemoExecutor.showDemo(componentDemo, true, logLevel), + DemoExecutor.showDemoWithoutSetup(componentDemo, true), componentDemo); } diff --git a/core/src/test/java/com/github/weisj/darklaf/ui/demo/DemoExecutor.java b/core/src/test/java/com/github/weisj/darklaf/ui/demo/DemoExecutor.java index a75f82a7..ca9ee168 100644 --- a/core/src/test/java/com/github/weisj/darklaf/ui/demo/DemoExecutor.java +++ b/core/src/test/java/com/github/weisj/darklaf/ui/demo/DemoExecutor.java @@ -1,7 +1,7 @@ /* * MIT License * - * Copyright (c) 2021 Jannis Weis + * Copyright (c) 2021-2022 Jannis Weis * * Permission is hereby granted, free of charge, to any person obtaining a copy of this software and * associated documentation files (the "Software"), to deal in the Software without restriction, @@ -25,7 +25,6 @@ import java.awt.Dimension; import java.awt.Toolkit; import java.awt.Window; import java.util.concurrent.atomic.AtomicReference; -import java.util.logging.Level; import javax.swing.Icon; import javax.swing.JDialog; @@ -55,16 +54,14 @@ public final class DemoExecutor { showDemo(demo, false); } - public static AtomicReference showDemo(final ComponentDemo demo, final boolean asDialog, - final Level logLevel) { - LafManager.setLogLevel(logLevel != null ? logLevel : Level.FINE); - return showDemo(demo, asDialog); - } - public static AtomicReference showDemo(final ComponentDemo demo, final boolean asDialog) { InspectorKt.installInspector(); LafManager.enabledPreferenceChangeReporting(false); LafManager.addThemePreferenceChangeListener(LafManager::installTheme); + return showDemoWithoutSetup(demo, asDialog); + } + + public static AtomicReference showDemoWithoutSetup(final ComponentDemo demo, final boolean asDialog) { AtomicReference windowRef = new AtomicReference<>(); DemoExecutionSpec executionSpec = demo.getExecutionSpec(); @@ -88,6 +85,13 @@ public final class DemoExecutor { windowRef.notifyAll(); } }); + synchronized (windowRef) { + try { + windowRef.wait(); + } catch (InterruptedException e) { + throw new IllegalStateException(e); + } + } return windowRef; }