1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/layout"# ] |
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 | // Regression test for a panic in the compiler |
6 | |
7 | TestCase := Rectangle { |
8 | width: 300phx; |
9 | height: 300phx; |
10 | property<int> value: 1; |
11 | |
12 | for c[index] in [#f00, #00f, #0a0]: Rectangle { |
13 | y: index * height; |
14 | width: parent.width; |
15 | height: 100phx; |
16 | GridLayout { |
17 | Rectangle { |
18 | background: c; |
19 | |
20 | TouchArea { |
21 | width: parent.width; |
22 | height: parent.height; |
23 | clicked => { |
24 | value += index; |
25 | } |
26 | } |
27 | } |
28 | } |
29 | } |
30 | } |
31 | |
32 | |
33 | /* |
34 | ```cpp |
35 | auto handle = TestCase::create(); |
36 | const TestCase &instance = *handle; |
37 | slint_testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout |
38 | |
39 | slint_testing::send_mouse_click(&instance, 190., 190.); |
40 | assert_eq(instance.get_value(), 1+1); |
41 | |
42 | slint_testing::send_mouse_click(&instance, 5., 290.); |
43 | assert_eq(instance.get_value(), 1+1+2); |
44 | ``` |
45 | |
46 | |
47 | ```rust |
48 | let instance = TestCase::new().unwrap(); |
49 | slint_testing::send_mouse_click(&instance, -1., -1.); // FIXME: Force creation of repeater components before computing the layout |
50 | |
51 | |
52 | slint_testing::send_mouse_click(&instance, 190., 190.); |
53 | assert_eq!(instance.get_value(), 1+1); |
54 | |
55 | slint_testing::send_mouse_click(&instance, 5., 290.); |
56 | assert_eq!(instance.get_value(), 1+1+2); |
57 | |
58 | ``` |
59 | |
60 | // FIXME: JS test because layout are not computed |
61 | */ |
62 | } |
63 | |
64 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
65 | use i_slint_backend_testing as slint_testing; |
66 | slint_testing::init(); |
67 | let instance = TestCase::new().unwrap(); |
68 | slint_testing::send_mouse_click(&instance, x:-1., y:-1.); // FIXME: Force creation of repeater components before computing the layout |
69 | |
70 | |
71 | slint_testing::send_mouse_click(&instance, x:190., y:190.); |
72 | assert_eq!(instance.get_value(), 1+1); |
73 | |
74 | slint_testing::send_mouse_click(&instance, x:5., y:290.); |
75 | assert_eq!(instance.get_value(), 1+1+2); |
76 | |
77 | Ok(()) |
78 | } |