1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements"# ] |
2 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
3 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
4 | |
5 | // Allow for accessing built-in functions on root elements even with an injected window item |
6 | |
7 | export component TestCase inherits TextInput { |
8 | width: 100phx; |
9 | height: 100phx; |
10 | |
11 | out property<bool> selection-set; |
12 | |
13 | text: "Hello World" ; |
14 | if (true): TouchArea { |
15 | clicked => { |
16 | root.select-all(); |
17 | root.selection-set = root.anchor-position-byte-offset == 0 && root.cursor-position-byte-offset == 11; |
18 | } |
19 | } |
20 | } |
21 | |
22 | /* |
23 | |
24 | ```cpp |
25 | auto handle = TestCase::create(); |
26 | const TestCase &instance = *handle; |
27 | assert(!instance.get_selection_set()); |
28 | slint_testing::send_mouse_click(&instance, 5., 5.); |
29 | assert(instance.get_selection_set()); |
30 | ``` |
31 | |
32 | ```rust |
33 | let instance = TestCase::new().unwrap(); |
34 | assert!(!instance.get_selection_set()); |
35 | slint_testing::send_mouse_click(&instance, 5., 5.); |
36 | assert!(instance.get_selection_set()); |
37 | ``` |
38 | |
39 | ```js |
40 | var instance = new slint.TestCase(); |
41 | assert(!instance.selection_set); |
42 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
43 | assert(instance.selection_set); |
44 | ``` |
45 | */ |
46 | } |
47 | |
48 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
49 | use i_slint_backend_testing as slint_testing; |
50 | slint_testing::init(); |
51 | let instance = TestCase::new().unwrap(); |
52 | assert!(!instance.get_selection_set()); |
53 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
54 | assert!(instance.get_selection_set()); |
55 | Ok(()) |
56 | } |