1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/bindings"# ] |
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 | |
6 | |
7 | |
8 | TestCase := Rectangle { |
9 | width: 100phx; |
10 | height: 100phx; |
11 | |
12 | property<length> xx: 50phx; |
13 | property<length> ww <=> first.width; |
14 | |
15 | first := TouchArea { |
16 | x <=> parent.xx; |
17 | width: 50phx; |
18 | enabled <=> second.enabled; |
19 | height: 15phx; |
20 | clicked => { result += 40; } |
21 | } |
22 | |
23 | second := TouchArea { |
24 | x <=> parent.xx; |
25 | width <=> root.ww; |
26 | height <=> first.height; |
27 | clicked => { result += 300; } |
28 | y: 50phx; |
29 | } |
30 | |
31 | property <int> result: 5; |
32 | } |
33 | |
34 | |
35 | |
36 | /* |
37 | |
38 | ```rust |
39 | let instance = TestCase::new().unwrap(); |
40 | slint_testing::send_mouse_click(&instance, 70., 5.); |
41 | slint_testing::send_mouse_click(&instance, 85., 55.); |
42 | assert_eq!(instance.get_result(), 345); |
43 | instance.set_xx(0.); |
44 | slint_testing::send_mouse_click(&instance, 5., 10.); |
45 | slint_testing::send_mouse_click(&instance, 5., 60.); |
46 | assert_eq!(instance.get_result(), 685); |
47 | |
48 | ``` |
49 | |
50 | |
51 | |
52 | ```cpp |
53 | auto handle = TestCase::create(); |
54 | const TestCase &instance = *handle; |
55 | slint_testing::send_mouse_click(&instance, 70., 5.); |
56 | slint_testing::send_mouse_click(&instance, 85., 55.); |
57 | assert_eq(instance.get_result(), 345); |
58 | instance.set_xx(0.); |
59 | slint_testing::send_mouse_click(&instance, 5., 10.); |
60 | slint_testing::send_mouse_click(&instance, 5., 60.); |
61 | assert_eq(instance.get_result(), 685); |
62 | ``` |
63 | |
64 | |
65 | ```js |
66 | let instance = new slint.TestCase({}); |
67 | slintlib.private_api.send_mouse_click(instance, 70., 5.); |
68 | slintlib.private_api.send_mouse_click(instance, 85., 55.); |
69 | assert.equal(instance.result, 345); |
70 | instance.xx = 0; |
71 | slintlib.private_api.send_mouse_click(instance, 5., 10.); |
72 | slintlib.private_api.send_mouse_click(instance, 5., 60.); |
73 | assert.equal(instance.result, 685); |
74 | ``` |
75 | |
76 | */ |
77 | } |
78 | |
79 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
80 | use i_slint_backend_testing as slint_testing; |
81 | slint_testing::init(); |
82 | let instance = TestCase::new().unwrap(); |
83 | slint_testing::send_mouse_click(&instance, x:70., y:5.); |
84 | slint_testing::send_mouse_click(&instance, x:85., y:55.); |
85 | assert_eq!(instance.get_result(), 345); |
86 | instance.set_xx(0.); |
87 | slint_testing::send_mouse_click(&instance, x:5., y:10.); |
88 | slint_testing::send_mouse_click(&instance, x:5., y:60.); |
89 | assert_eq!(instance.get_result(), 685); |
90 | |
91 | Ok(()) |
92 | } |