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 | MyTextInput := TextInput { } |
6 | |
7 | TextComponent := Rectangle { |
8 | property<bool> has_focus: my_text_input.has_focus; |
9 | forward-focus: my_text_input; |
10 | my_text_input := MyTextInput { } |
11 | |
12 | callback not_called; |
13 | not_called => { |
14 | if (false) { |
15 | my_text_input.focus(); |
16 | } |
17 | } |
18 | } |
19 | |
20 | TestCase := Rectangle { |
21 | width: 400phx; |
22 | height: 400phx; |
23 | forward-focus: input2; |
24 | |
25 | input1 := TextComponent { |
26 | } |
27 | input2 := TextComponent { |
28 | } |
29 | |
30 | callback not_called; |
31 | not_called => { |
32 | input1.focus(); |
33 | } |
34 | |
35 | property<bool> input1_focused: input1.has_focus; |
36 | property<bool> input2_focused: input2.has_focus; |
37 | } |
38 | |
39 | /* |
40 | ```rust |
41 | let instance = TestCase::new().unwrap(); |
42 | assert!(!instance.get_input1_focused()); |
43 | assert!(instance.get_input2_focused()); |
44 | ``` |
45 | |
46 | ```cpp |
47 | auto handle = TestCase::create(); |
48 | const TestCase &instance = *handle; |
49 | assert(!instance.get_input1_focused()); |
50 | assert(instance.get_input2_focused()); |
51 | ``` |
52 | |
53 | ```js |
54 | var instance = new slint.TestCase(); |
55 | assert(!instance.input1_focused); |
56 | assert(instance.input2_focused); |
57 | ``` |
58 | */ |
59 | } |
60 | |
61 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
62 | use i_slint_backend_testing as slint_testing; |
63 | slint_testing::init(); |
64 | let instance = TestCase::new().unwrap(); |
65 | assert!(!instance.get_input1_focused()); |
66 | assert!(instance.get_input2_focused()); |
67 | Ok(()) |
68 | } |