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 | |
5 | TextComponent := 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 | |
13 | TestCase := 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 |
29 | let instance = TestCase::new().unwrap(); |
30 | assert!(!instance.get_input1_focused()); |
31 | assert!(instance.get_input2_focused()); |
32 | ``` |
33 | |
34 | ```cpp |
35 | auto handle = TestCase::create(); |
36 | const TestCase &instance = *handle; |
37 | assert(!instance.get_input1_focused()); |
38 | assert(instance.get_input2_focused()); |
39 | ``` |
40 | |
41 | ```js |
42 | var instance = new slint.TestCase(); |
43 | assert(!instance.input1_focused); |
44 | assert(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 | } |