| 1 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
| 2 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0 |
| 3 | |
| 4 | TestCase := Window { |
| 5 | width: 100phx; |
| 6 | height: 100phx; |
| 7 | VerticalLayout { |
| 8 | padding: 0; |
| 9 | spacing: 0; |
| 10 | ti := TextInput { } |
| 11 | Rectangle { } |
| 12 | } |
| 13 | |
| 14 | property <string> text <=> ti.text; |
| 15 | property <bool> input_focused: ti.has_focus; |
| 16 | property<int> test_cursor_pos: ti.cursor_position_byte_offset; |
| 17 | } |
| 18 | |
| 19 | /* |
| 20 | ```rust |
| 21 | |
| 22 | const LEFT_CODE: char = '\u{F702}'; |
| 23 | |
| 24 | let instance = TestCase::new().unwrap(); |
| 25 | slint_testing::send_mouse_click(&instance, 5., 5.); |
| 26 | assert!(instance.get_input_focused()); |
| 27 | assert_eq!(instance.get_text(), ""); |
| 28 | slint_testing::send_keyboard_string_sequence(&instance, "Hallo"); |
| 29 | assert_eq!(instance.get_text(), "Hallo"); |
| 30 | instance.set_text("Yo".into()); |
| 31 | assert_eq!(instance.get_text(), "Yo"); |
| 32 | slint_testing::send_keyboard_string_sequence(&instance, "Hello Again"); |
| 33 | assert_eq!(instance.get_text(), "YoHello Again"); |
| 34 | instance.set_text("Yo".into()); |
| 35 | // Issue #331: assert_eq!(instance.get_test_cursor_pos(), 2); |
| 36 | slint_testing::send_keyboard_string_sequence(&instance, &LEFT_CODE.to_string()); |
| 37 | assert_eq!(instance.get_test_cursor_pos(), 1); |
| 38 | ``` |
| 39 | */ |
| 40 | |