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 6d7a9667..114432c4 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 @@ -33,6 +33,9 @@ import java.util.logging.Logger; import java.util.stream.Collector; import java.util.stream.Collectors; +import com.github.weisj.darklaf.ui.demo.ComponentDemo; +import com.github.weisj.darklaf.ui.demo.DemoSpec; +import com.github.weisj.darklaf.util.Pair; import org.junit.jupiter.api.Assertions; import org.junit.jupiter.api.Test; @@ -42,11 +45,13 @@ import com.github.weisj.darklaf.ui.DemoLauncher; import com.github.weisj.darklaf.util.Lambdas; import com.github.weisj.darklaf.util.LogUtil; +import javax.swing.JComponent; import javax.swing.UIManager; class DemoTest implements NonThreadSafeTest { private static final Logger LOGGER = LogUtil.getLogger(DemoTest.class); + private static final boolean EXTENSIVE = false; @Test void runningDemosDoesNotThrow() { @@ -86,7 +91,9 @@ class DemoTest implements NonThreadSafeTest { return; } try { - AtomicReference windowRef = demo.start(Level.WARNING); + Pair, ComponentDemo> startedDemo = demo.start(Level.WARNING); + AtomicReference windowRef = startedDemo.getFirst(); + ComponentDemo componentDemo = startedDemo.getSecond(); if (robot != null) robot.waitForIdle(); synchronized (windowRef) { while (windowRef.get() == null) { @@ -95,6 +102,9 @@ class DemoTest implements NonThreadSafeTest { } TestUtils.runOnSwingThreadNotThrowing( () -> Assertions.assertNotNull(windowRef.get())); + TestUtils.runOnSwingThreadNotThrowing( + () -> testConfigurations(componentDemo)); + if (!demo.isDarklafOnly()) { TestUtils.runOnSwingThreadNotThrowing(() -> { UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); @@ -109,4 +119,20 @@ class DemoTest implements NonThreadSafeTest { } } + private void testConfigurations(final ComponentDemo demo) { + if (!EXTENSIVE) return; + final List> specs = demo.getSpecs(); + testConfigurations(demo.getComponent(), specs, 0); + } + + @SuppressWarnings("unchecked") + private void testConfigurations(final JComponent c, final List> specs, final int index) { + if (index >= specs.size()) return; + DemoSpec spec = (DemoSpec) specs.get(index); + for (Object possibleValue : spec.getPossibleValues()) { + spec.set(c, possibleValue); + testConfigurations(c, specs, index + 1); + } + } + } 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 3ed1a81a..da95729b 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 @@ -36,6 +36,8 @@ import com.github.weisj.darklaf.core.test.util.Instantiable; import com.github.weisj.darklaf.ui.demo.BaseComponentDemo; import com.github.weisj.darklaf.ui.demo.ComponentDemo; import com.github.weisj.darklaf.ui.demo.DemoExecutor; +import com.github.weisj.darklaf.util.LazyValue; +import com.github.weisj.darklaf.util.Pair; public class DemoLauncher extends BaseComponentDemo { @@ -91,11 +93,14 @@ public class DemoLauncher extends BaseComponentDemo { } public AtomicReference start() { - return start(null); + return start(null).getFirst(); } - public AtomicReference start(final Level logLevel) { - return DemoExecutor.showDemo(demo.instantiate(), true, logLevel); + public Pair, ComponentDemo> start(final Level logLevel) { + ComponentDemo componentDemo = demo.instantiate(); + return new Pair<>( + DemoExecutor.showDemo(componentDemo, true, logLevel), + componentDemo); } @Override