1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/focus"#]
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
5TextComponent := GridLayout {
6 property<bool> has_focus: my_text_input.has_focus;
7 forward-focus: my_text_input;
8 Row {
9 my_text_input := TextInput { }
10 }
11}
12
13TestCase := Rectangle {
14 width: 400phx;
15 height: 400phx;
16 forward-focus: input2;
17
18 input1 := TextComponent {
19 }
20 input2 := TextComponent {
21 }
22
23 property<bool> input1_focused: input1.has_focus;
24 property<bool> input2_focused: input2.has_focus;
25}
26
27/*
28```rust
29let instance = TestCase::new().unwrap();
30assert!(!instance.get_input1_focused());
31assert!(instance.get_input2_focused());
32```
33
34```cpp
35auto handle = TestCase::create();
36const TestCase &instance = *handle;
37assert(!instance.get_input1_focused());
38assert(instance.get_input2_focused());
39```
40
41```js
42var instance = new slint.TestCase();
43assert(!instance.input1_focused);
44assert(instance.input2_focused);
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_input1_focused());
54 assert!(instance.get_input2_focused());
55 Ok(())
56}