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
4TestCase := TextInput {
5 width: 100phx;
6 height: 100phx;
7 property<string> test_text: self.text;
8 property<int> test_cursor_pos: self.cursor_position_byte_offset;
9 property<int> test_anchor_pos: self.anchor_position_byte_offset;
10 property<bool> has_selection: self.test_cursor_pos != self.test_anchor_pos;
11 property<bool> input_focused: self.has_focus;
12}
13
14/*
15```rust
16
17let instance = TestCase::new().unwrap();
18slint_testing::send_mouse_click(&instance, 50., 50.);
19assert!(instance.get_input_focused());
20assert_eq!(instance.get_test_text(), "");
21slint_testing::send_keyboard_string_sequence(&instance, "Test");
22assert_eq!(instance.get_test_text(), "Test");
23assert!(!instance.get_has_selection());
24
25slint_testing::send_keyboard_char(&instance, slint::private_unstable_api::re_exports::Key::Control.into(), true);
26slint_testing::send_keyboard_string_sequence(&instance, "a");
27slint_testing::send_keyboard_char(&instance, slint::private_unstable_api::re_exports::Key::Control.into(), true);
28assert!(instance.get_has_selection());
29assert_eq!(instance.get_test_cursor_pos(), 4);
30assert_eq!(instance.get_test_anchor_pos(), 0);
31```
32*/
33