On Thu, 12 Dec 2019 15:54:11 GMT, Kevin Rushforth <k...@openjdk.org> wrote:
>> The following comment from @swpalmer sent to the openjfx-dev mailing list >> wasn't mirrored in the PR (I have alerted the Skara team about this). >> >> ---- >> From: Scott Palmer >> >>> I think a new `TextFlowTest.java` would be a good place for those tests. >> >> My first attempt at unit tests for TextFlow are failing. I believe the >> StubTextLayout is not equipped to handle TextFlow. This may be a bigger job… >> >> This fragment triggers a NPE: >> ... >> Toolkit tk = (StubToolkit) Toolkit.getToolkit(); >> HBox root = new HBox(); >> Scene scene = new Scene(root); >> Stage stage = new Stage(); >> stage.setScene(scene); >> stage.setWidth(300); >> stage.setHeight(200); >> >> try { >> Text text1 = new Text("\tfirst"); >> Text text2 = new Text("\tsecond"); >> TextFlow textFlow = new TextFlow(text1, text2); >> root.getChildren().addAll(textFlow); >> stage.show(); >> ... >> >> test.javafx.scene.text.TextFlowTest > testTabSize FAILED >> java.lang.NullPointerException >> at >> test.com.sun.javafx.pgstub.StubTextLayout.getBounds(StubTextLayout.java:88) >> at >> test.com.sun.javafx.pgstub.StubTextLayout.getBounds(StubTextLayout.java:82) >> at >> javafx.graphics/javafx.scene.text.TextFlow.computePrefWidth(TextFlow.java:254) >> at javafx.graphics/javafx.scene.Parent.prefWidth(Parent.java:1019) >> at >> javafx.graphics/javafx.scene.layout.Region.prefWidth(Region.java:1543) >> at >> javafx.graphics/javafx.scene.layout.Region.computeChildPrefAreaWidth(Region.java:1946) >> at >> javafx.graphics/javafx.scene.layout.HBox.getAreaWidths(HBox.java:465) >> at >> javafx.graphics/javafx.scene.layout.HBox.computeContentWidth(HBox.java:540) >> at >> javafx.graphics/javafx.scene.layout.HBox.computePrefWidth(HBox.java:433) >> at javafx.graphics/javafx.scene.Parent.prefWidth(Parent.java:1019) >> at >> javafx.graphics/javafx.scene.layout.Region.prefWidth(Region.java:1543) >> at >> javafx.graphics/javafx.scene.Scene.getPreferredWidth(Scene.java:1799) >> at >> javafx.graphics/javafx.scene.Scene.resizeRootToPreferredSize(Scene.java:1779) >> at javafx.graphics/javafx.scene.Scene.preferredSize(Scene.java:1747) >> at javafx.graphics/javafx.scene.Scene$2.preferredSize(Scene.java:393) >> at >> javafx.graphics/com.sun.javafx.scene.SceneHelper.preferredSize(SceneHelper.java:66) >> at >> javafx.graphics/javafx.stage.Window$12.invalidated(Window.java:1086) >> at >> javafx.base/javafx.beans.property.BooleanPropertyBase.markInvalid(BooleanPropertyBase.java:110) >> at >> javafx.base/javafx.beans.property.BooleanPropertyBase.set(BooleanPropertyBase.java:145) >> at javafx.graphics/javafx.stage.Window.setShowing(Window.java:1174) >> at javafx.graphics/javafx.stage.Window.show(Window.java:1189) >> at javafx.graphics/javafx.stage.Stage.show(Stage.java:273) >> at >> test.javafx.scene.text.TextFlowTest.testTabSize(TextFlowTest.java:60) >> >> Scott > > In that case, I recommend just doing the API get/set tests for `TextFlow` > without creating a `Scene` or `Stage`. This won't need anything from the > `StubToolkit`. In my attempts to address the issue with StubTextLayout I discovered bugs. TextFlow is NOT properly overriding the tabSize of the Text nodes. If you set the Text node tab size later, the layout reacts and adjusts to the tabSize of the Text node even though it is contained in a TextFlow. Whichever node changes the tabSize last affects the layout. I'm going to have to study this more, but this change isn't ready at this point. ------------- PR: https://git.openjdk.java.net/jfx/pull/32