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