1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/subcomponents"# ] |
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 | // Verify that two repeaters (if and for) are placed correctly in the item tree |
6 | // and matched in the dyn_visit closure. |
7 | // The two repeaters ended up being swapped and sub-component's repeater was |
8 | // visited when the Text's child's repeater should have been, resulting in |
9 | // wrong rendering order. This is tested by clicking into the left half and |
10 | // verifying that it did not hit the sub-component's repeater. |
11 | |
12 | SubCompo := Rectangle { |
13 | property <bool> clicked: false; |
14 | for x in 1: Text { |
15 | text: "I should appear in the right half" ; |
16 | ta := TouchArea { |
17 | clicked => { |
18 | root.clicked = true; |
19 | } |
20 | } |
21 | } |
22 | } |
23 | |
24 | TestCase := Rectangle { |
25 | width: 300phx; |
26 | height: 300phx; |
27 | property clicked <=> c.clicked; |
28 | Text { |
29 | if (false): TouchArea { |
30 | } |
31 | } |
32 | c := SubCompo { |
33 | x: 200px; |
34 | } |
35 | } |
36 | |
37 | /* |
38 | ```rust |
39 | let instance = TestCase::new().unwrap(); |
40 | |
41 | assert!(!instance.get_clicked()); |
42 | slint_testing::send_mouse_click(&instance, 20., 5.); |
43 | assert!(!instance.get_clicked()); |
44 | ``` |
45 | |
46 | ```cpp |
47 | auto handle = TestCase::create(); |
48 | const TestCase &instance = *handle; |
49 | assert(!instance.get_clicked()); |
50 | slint_testing::send_mouse_click(&instance, 20., 5.); |
51 | assert(!instance.get_clicked()); |
52 | ``` |
53 | |
54 | |
55 | ```js |
56 | var instance = new slint.TestCase({}); |
57 | assert(!instance.clicked); |
58 | slintlib.private_api.send_mouse_click(instance, 20., 5.); |
59 | assert(!instance.clicked); |
60 | ``` |
61 | |
62 | |
63 | */ |
64 | } |
65 | |
66 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
67 | use i_slint_backend_testing as slint_testing; |
68 | slint_testing::init(); |
69 | let instance = TestCase::new().unwrap(); |
70 | |
71 | assert!(!instance.get_clicked()); |
72 | slint_testing::send_mouse_click(&instance, x:20., y:5.); |
73 | assert!(!instance.get_clicked()); |
74 | Ok(()) |
75 | } |