On Fri, 14 Mar 2025 16:27:09 GMT, Andy Goryachev <ango...@openjdk.org> wrote:
>> With the new approach the `promptText` property is accepting any value so >> it's expected to have prompt text with Linebreaks for `TextField` and >> `PasswordField`, is this the test that I have to keep ? >> >> Else to have a test that uses `stage` in `TextInputControlTest` we will have >> to check for the Class type in many cases since >> `TextInputSkinShim::getPromptNode` have two overloaded methods for >> `TextArea` and `TextField` >> It will look like this in the test : >> >> >> SkinBase<?> skin; >> if (type.equals(TextField.class)) { >> textInput = new TextField(); >> skin = new TextFieldSkin((TextField) textInput); >> } else if (type.equals(PasswordField.class)) { >> textInput = new PasswordField(); >> skin = new TextFieldSkin((TextField) textInput); >> } else if (type.equals(TextArea.class)) { >> textInput = new TextArea(); >> skin = new TextAreaSkin((TextArea) textInput); >> } >> >> //test logic >> >> if (type.equals(TextField.class) || type.equals(PasswordField.class)) { >> promptNode = TextInputSkinShim.getPromptNode((TextField) >> textInput); >> } else { >> promptNode = TextInputSkinShim.getPromptNode((TextArea) >> textInput); >> } > > If the code gets more complicated it might be better to use your initial > approach and move the tests into separate classes (but remember the > PasswordField lost its test cases - this might be ok since the methods and > the logic being tested is identical between `TextField` and `PasswordField`). > > Another option, for the sake of discussion, is to use a more complex > parameter instead of simple `Class` for the parameterized test. Take a look > at the `LabelSkinCreationTest` - there the parameterized test iterates a list > of `Parameters` which packs more data. So you could, for example, supply > more arguments to each test: the skin class, the getter, a flag that > indicates whether the stage is needed, the expected string. > > What do you think? I guess we will keep it like this as you said since tested is identical between TextField and PasswordField ------------- PR Review Comment: https://git.openjdk.org/jfx/pull/1716#discussion_r2013039465