1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/callbacks"# ] |
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 the init callback is invoked in the correct order |
6 | |
7 | TestCase := Rectangle { |
8 | width: 300phx; |
9 | height: 300phx; |
10 | |
11 | out property <bool> popup-created; |
12 | |
13 | popup := PopupWindow { |
14 | init => { |
15 | root.popup-created = true; |
16 | } |
17 | } |
18 | |
19 | TouchArea { |
20 | clicked => { |
21 | popup.show(); |
22 | } |
23 | } |
24 | } |
25 | |
26 | /* |
27 | ```rust |
28 | let instance = TestCase::new().unwrap(); |
29 | |
30 | slint_testing::send_mouse_click(&instance, 5., 5.); |
31 | assert!(instance.get_popup_created()); |
32 | ``` |
33 | |
34 | ```cpp |
35 | auto handle = TestCase::create(); |
36 | const TestCase &instance = *handle; |
37 | slint_testing::send_mouse_click(&instance, 5., 5.); |
38 | assert(instance.get_popup_created()); |
39 | ``` |
40 | |
41 | |
42 | ```js |
43 | var instance = new slint.TestCase({}); |
44 | slintlib.private_api.send_mouse_click(instance, 5., 5.); |
45 | assert(instance.popup_created); |
46 | ``` |
47 | |
48 | |
49 | */ |
50 | } |
51 | |
52 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
53 | use i_slint_backend_testing as slint_testing; |
54 | slint_testing::init(); |
55 | let instance = TestCase::new().unwrap(); |
56 | |
57 | slint_testing::send_mouse_click(&instance, x:5., y:5.); |
58 | assert!(instance.get_popup_created()); |
59 | Ok(()) |
60 | } |