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
7export 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
26auto handle = TestCase::create();
27const TestCase &instance = *handle;
28assert(!instance.get_combo_has_focus());
29slint_testing::send_mouse_click(&instance, 5., 5.);
30assert(instance.get_combo_has_focus());
31```
32
33```rust
34let instance = TestCase::new().unwrap();
35assert!(!instance.get_combo_has_focus());
36slint_testing::send_mouse_click(&instance, 5., 5.);
37assert!(instance.get_combo_has_focus());
38```
39
40```js
41var instance = new slint.TestCase();
42assert(!instance.combo_has_focus);
43slintlib.private_api.send_mouse_click(instance, 5., 5.);
44assert(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}