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 | import { Button } from "std-widgets.slint" ; |
6 | |
7 | TestCase := Rectangle { |
8 | property <bool> checked <=> tb.checked; |
9 | |
10 | tb := Button { |
11 | width: 100px; |
12 | height: 100px; |
13 | |
14 | checkable: true; |
15 | checked: true; |
16 | } |
17 | } |
18 | |
19 | /* |
20 | ```cpp |
21 | auto handle = TestCase::create(); |
22 | const TestCase &instance = *handle; |
23 | assert(instance.get_checked()); |
24 | |
25 | // click on button |
26 | slint_testing::send_mouse_click(&instance, 50., 50.); |
27 | assert(!instance.get_checked()); |
28 | |
29 | // click on button again |
30 | slint_testing::send_mouse_click(&instance, 50., 50.); |
31 | assert(instance.get_checked()); |
32 | |
33 | ``` |
34 | |
35 | |
36 | ```rust |
37 | let instance = TestCase::new().unwrap(); |
38 | assert!(instance.get_checked()); |
39 | |
40 | // click on button |
41 | slint_testing::send_mouse_click(&instance, 50., 50.); |
42 | assert!(!instance.get_checked()); |
43 | |
44 | // click on button again |
45 | slint_testing::send_mouse_click(&instance, 50., 50.); |
46 | assert!(instance.get_checked()); |
47 | |
48 | ``` |
49 | |
50 | ```js |
51 | var instance = new slint.TestCase(); |
52 | assert.equal(instance.checked, true); |
53 | |
54 | // click on button |
55 | slintlib.private_api.send_mouse_click(instance, 50., 50.); |
56 | assert.equal(instance.checked, false); |
57 | |
58 | // click on button |
59 | slintlib.private_api.send_mouse_click(instance, 50., 50.); |
60 | assert.equal(instance.checked, true); |
61 | ``` |
62 | */ |
63 | } |
64 | |
65 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
66 | use i_slint_backend_testing as slint_testing; |
67 | slint_testing::init(); |
68 | let instance = TestCase::new().unwrap(); |
69 | assert!(instance.get_checked()); |
70 | |
71 | // click on button |
72 | slint_testing::send_mouse_click(&instance, x:50., y:50.); |
73 | assert!(!instance.get_checked()); |
74 | |
75 | // click on button again |
76 | slint_testing::send_mouse_click(&instance, x:50., y:50.); |
77 | assert!(instance.get_checked()); |
78 | |
79 | Ok(()) |
80 | } |