CSS changes not detected

62 views
Skip to first unread message

Tom Eugelink

unread,
Dec 26, 2013, 3:22:19 PM12/26/13
to testfx-...@googlegroups.com


Let me start by deeply thanking you for providing a better alternative for JemmyFX. I've been so reluctant to start writing tests because of the framework, but TestFX simply works as I expect.

That said, I'm already running into my first issue. I have a control that has CSS styleable properties called ListSpinner (available in JFXtras, similar to Swing's Spinner component). One of these properties is the "arrow direction", which allows positioning the arrow horizontally or vertically. In horizontal mode there is a right-arrow and left-arrow class assigned, in vertical mode an up-arrow and down-arrow. The tests I am writing is to assert each arrow has the correct behavior, right/up increments, left/down decrements. Default is the horizontal mode

First I try to set the arrow direction through CSS, like so:

    spinner.setStyle("-fxx-arrow-direction: " + ListSpinnerCaspianSkin.ArrowDirection.VERTICAL);

That results in an exception:
    java.lang.IllegalStateException: Not on FX application thread; currentThread = main
at com.sun.javafx.tk.Toolkit.checkFxUserThread(Toolkit.java:210)
at com.sun.javafx.tk.quantum.QuantumToolkit.checkFxUserThread(QuantumToolkit.java:393)
at javafx.scene.Scene.addToDirtyList(Scene.java:521)
at javafx.scene.Node.addToSceneDirtyList(Node.java:417)
at javafx.scene.Node.impl_markDirty(Node.java:408)
at javafx.scene.Node.notifyParentsOfInvalidatedCSS(Node.java:8664)
at javafx.scene.Node$6.invalidated(Node.java:1054)
at javafx.beans.property.StringPropertyBase.markInvalid(StringPropertyBase.java:109)
at javafx.beans.property.StringPropertyBase.set(StringPropertyBase.java:143)
at javafx.scene.Node$6.set(Node.java:1042)
at javafx.scene.Node$6.set(Node.java:1036)
at javafx.scene.Node.setStyle(Node.java:1014)
at jfxtras.labs.scene.control.test.ListSpinnerArrowTest.navigateUpDownThroughTheValuesNonCyclic(ListSpinnerArrowTest.java:175)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)

So I move it into a runAndWait method:

PlatformUtil.runAndWait( () -> {
spinner.setStyle("-fxx-arrow-direction: " + ListSpinnerCaspianSkin.ArrowDirection.VERTICAL);
});

That also results in an exception.

    org.loadui.testfx.exceptions.NoNodesFoundException: No nodes matched the CSS query '.up-arrow'! Screenshot saved as C:\Users\user\Documents\jfxtras-labs-8.0\screenshot1388088842878.png
at org.loadui.testfx.GuiTest.find(GuiTest.java:296)
at org.loadui.testfx.GuiTest.pointFor(GuiTest.java:1110)
at org.loadui.testfx.GuiTest.move(GuiTest.java:801)
at org.loadui.testfx.GuiTest.click(GuiTest.java:595)
at jfxtras.labs.scene.control.test.ListSpinnerArrowTest.navigateUpDownThroughTheValuesNonCyclic(ListSpinnerArrowTest.java:186)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:45)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:15)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:42)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:20)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:28)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.junit.runner.JUnitCore.run(JUnitCore.java:157)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:74)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:202)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:65)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)


 Apparently the CSS change is not processed and the newly assigned classes are not detected (I verified that they were assigned). So now I call the styleable property directly:
PlatformUtil.runAndWait( () -> {
((ListSpinnerCaspianSkin)spinner.getSkin()).arrowDirectionProperty().set(ListSpinnerCaspianSkin.ArrowDirection.VERTICAL);
});

This works. How can I do the CSS version?
Reply all
Reply to author
Forward
0 new messages