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 | TestCase := Window { |
6 | width: 300px; |
7 | height: 300px; |
8 | if (true) : Rectangle { |
9 | background: black; |
10 | VerticalLayout { |
11 | Rectangle { |
12 | background: blue; |
13 | TouchArea { clicked => { last_clicked = 1; } } |
14 | } |
15 | Rectangle { |
16 | background: red; |
17 | TouchArea { clicked => { last_clicked = 2; } } |
18 | } |
19 | } |
20 | } |
21 | property<int> last_clicked; |
22 | } |
23 | /* |
24 | ```cpp |
25 | auto handle = TestCase::create(); |
26 | const TestCase &instance = *handle; |
27 | assert_eq(instance.get_last_clicked(), 0); |
28 | slint_testing::send_mouse_click(&instance, 15., 145.); |
29 | assert_eq(instance.get_last_clicked(), 1); |
30 | slint_testing::send_mouse_click(&instance, 15., 155.); |
31 | assert_eq(instance.get_last_clicked(), 2); |
32 | ``` |
33 | |
34 | |
35 | ```rust |
36 | let instance = TestCase::new().unwrap(); |
37 | assert_eq!(instance.get_last_clicked(), 0); |
38 | slint_testing::send_mouse_click(&instance, 15., 145.); |
39 | assert_eq!(instance.get_last_clicked(), 1); |
40 | slint_testing::send_mouse_click(&instance, 15., 155.); |
41 | assert_eq!(instance.get_last_clicked(), 2); |
42 | ``` |
43 | |
44 | ```js |
45 | var instance = new slint.TestCase(); |
46 | assert.equal(instance.last_clicked, 0); |
47 | slintlib.private_api.send_mouse_click(instance, 15., 145.); |
48 | assert.equal(instance.last_clicked, 1); |
49 | slintlib.private_api.send_mouse_click(instance, 15., 155.); |
50 | assert.equal(instance.last_clicked, 2); |
51 | ``` |
52 | */ |
53 | } |
54 | |
55 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
56 | use i_slint_backend_testing as slint_testing; |
57 | slint_testing::init(); |
58 | let instance = TestCase::new().unwrap(); |
59 | assert_eq!(instance.get_last_clicked(), 0); |
60 | slint_testing::send_mouse_click(&instance, x:15., y:145.); |
61 | assert_eq!(instance.get_last_clicked(), 1); |
62 | slint_testing::send_mouse_click(&instance, x:15., y:155.); |
63 | assert_eq!(instance.get_last_clicked(), 2); |
64 | Ok(()) |
65 | } |