RFR: 8314906: [testbug] Create behavior tests for text input controls [v5]
Martin Fox
duke at openjdk.org
Tue Sep 19 19:52:51 UTC 2023
On Mon, 18 Sep 2023 21:14:30 GMT, Andy Goryachev <angorya at openjdk.org> wrote:
>> This is the behavior we saw on the Mac before PR #425 was integrated. As of JavaFX 21 keyPress(KeyCode.A) should generate an 'a' and never a 'q' on all Latin layouts and all platforms (on a Cyrillic layout you'll still get a Cyrillic character).
>>
>> I can't reproduce this with the test app (tests/manual/events/KeyboardTest.java). Is there a test in this PR I should be trying?
>
> You could try this code (using this PR's code):
>
>
> public class KeyboardLayoutTest extends TextInputBehaviorRobotTest<TextArea> {
>
> public KeyboardLayoutTest() {
> super(new TextArea());
> }
>
> @BeforeEach
> @Override
> public void beforeEach() {
> super.beforeEach();
> control.setWrapText(true);
> }
>
> @Test
> public void testTyping() throws Exception {
> KeyCode[] codes = {
> KeyCode.A
> };
>
> execute(
> exe(() -> {
> control.addEventFilter(KeyEvent.ANY, (ev) -> {
> System.out.println(ev);
> ev.consume();
> });
> })
> );
>
> for(KeyCode cd: codes) {
> Util.runAndWait(() -> {
> robot.keyPress(cd);
> robot.keyRelease(cd);
> });
> }
> }
> }
I tried your test code and couldn't reproduce the problem. Both U.S. English and French layouts gave me the expected result (an 'a' character). I also tried a Russian keyboard just to verify that it would generate a Cyrillic character which it did. I'm running the tests against JavaFX built using the sources in your pull request.
French
KeyEvent [source = TextArea at 7237703[styleClass=text-input text-area], target = TextArea at 7237703[styleClass=text-input text-area], eventType = KEY_PRESSED, consumed = false, character = ?, text = a, code = A]
KeyEvent [source = TextArea at 7237703[styleClass=text-input text-area], target = TextArea at 7237703[styleClass=text-input text-area], eventType = KEY_TYPED, consumed = false, character = a, text = , code = UNDEFINED]
KeyEvent [source = TextArea at 7237703[styleClass=text-input text-area], target = TextArea at 7237703[styleClass=text-input text-area], eventType = KEY_RELEASED, consumed = false, character = ?, text = a, code = A]
U.S. English
KeyEvent [source = TextArea at 73459ba5[styleClass=text-input text-area], target = TextArea at 73459ba5[styleClass=text-input text-area], eventType = KEY_PRESSED, consumed = false, character = ?, text = a, code = A]
KeyEvent [source = TextArea at 73459ba5[styleClass=text-input text-area], target = TextArea at 73459ba5[styleClass=text-input text-area], eventType = KEY_TYPED, consumed = false, character = a, text = , code = UNDEFINED]
KeyEvent [source = TextArea at 73459ba5[styleClass=text-input text-area], target = TextArea at 73459ba5[styleClass=text-input text-area], eventType = KEY_RELEASED, consumed = false, character = ?, text = a, code = A]
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/1221#discussion_r1330631833
More information about the openjfx-dev
mailing list