RFR: 8253935: [testbug] ComboBoxTest.testEditorKeyInputsWhenPopupIsShowing fails on Mac, Linux
Kevin Rushforth
kcr at openjdk.java.net
Mon Oct 12 20:19:10 UTC 2020
On Mon, 12 Oct 2020 19:37:41 GMT, Ambarish Rapte <arapte at openjdk.org> wrote:
> The test fails on Mac and Linux.
> Cause of failure:
> - Linux: Unlike Windows, on Linux CTRL + Arrow keys move the caret to end/beginning of current word and not to
> beginning/end of next word.
> - Mac: On Mac correct keys to traverse through words is ALT + Arrow and not CTRL + Arrow. And like on Linux, ALT + Arrow
> keys move the caret to end/beginning of current word and not to beginning/end of next word.
>
> Fix is to use correct keys and asserts according to platform.
The test changes look good, and pass for me on all three platforms. I left a couple suggestions for you to consider.
modules/javafx.controls/src/test/java/test/javafx/scene/control/ComboBoxTest.java line 1394:
> 1392: // Test CTRL + RIGHT key
> 1393: keyboard.doKeyPress(KeyCode.RIGHT, KeyModifier.getShortcutKey());
> 1394: }
Do you think it's worth adding another method to `KeyModifier` to encapsulate getting either ALT (on Mac) or the
shortcut-key (on Windows or Linux)? That will minimize the number of places that you need to check the platform.
modules/javafx.controls/src/test/java/test/javafx/scene/control/ComboBoxTest.java line 1400:
> 1398: } else {
> 1399: assertEquals(3, cb.getEditor().getCaretPosition());
> 1400: }
Similarly, you might want to compute the index up front with a single platform check, and then you can use that index,
both in the assert statements and to grab the expected selected text (using a substring call).
-------------
PR: https://git.openjdk.java.net/jfx/pull/317
More information about the openjfx-dev
mailing list