1 | #![allow (deprecated)]slint::slint!{#[style="cupertino" #] |
2 | #[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/widgets"# ] |
3 | // Copyright © SixtyFPS GmbH <info@slint.dev> |
4 | // SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-1.1 OR LicenseRef-Slint-commercial |
5 | |
6 | |
7 | // FIXME: Ignore the SpinBox test with the Qt style because it doesn't support editing (#4690) |
8 | //ignore: style-qt |
9 | |
10 | import { SpinBox } from "std-widgets.slint" ; |
11 | export component TestCase inherits Window { |
12 | width: 100px; |
13 | height: 100px; |
14 | box := SpinBox {} |
15 | forward-focus: box; |
16 | out property <bool> spinbox-focused <=> box.has_focus; |
17 | callback edited <=> box.edited; |
18 | } |
19 | |
20 | /* |
21 | |
22 | |
23 | ```rust |
24 | use slint::platform::Key; |
25 | use std::cell::RefCell; |
26 | use std::rc::Rc; |
27 | |
28 | let instance = TestCase::new().unwrap(); |
29 | slint_testing::send_mouse_click(&instance, 5., 5.); |
30 | assert!(instance.get_spinbox_focused()); |
31 | |
32 | let edits = Rc::new(RefCell::new(Vec::new())); |
33 | |
34 | instance.on_edited({ |
35 | let edits = edits.clone(); |
36 | move |val| { |
37 | edits.borrow_mut().push(val); |
38 | }}); |
39 | |
40 | slint_testing::send_keyboard_char(&instance, '4', true); |
41 | slint_testing::send_keyboard_char(&instance, Key::Return.into(), true); |
42 | |
43 | assert_eq!(edits.borrow().clone(), vec![40]); |
44 | |
45 | ``` |
46 | |
47 | */ |
48 | } |
49 | |
50 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
51 | use i_slint_backend_testing as slint_testing; |
52 | slint_testing::init(); |
53 | use slint::platform::Key; |
54 | use std::cell::RefCell; |
55 | use std::rc::Rc; |
56 | |
57 | let instance = TestCase::new().unwrap(); |
58 | slint_testing::send_mouse_click(&instance, 5., 5.); |
59 | assert!(instance.get_spinbox_focused()); |
60 | |
61 | let edits = Rc::new(RefCell::new(Vec::new())); |
62 | |
63 | instance.on_edited({ |
64 | let edits = edits.clone(); |
65 | move |val| { |
66 | edits.borrow_mut().push(val); |
67 | }}); |
68 | |
69 | slint_testing::send_keyboard_char(&instance, '4' , true); |
70 | slint_testing::send_keyboard_char(&instance, Key::Return.into(), true); |
71 | |
72 | assert_eq!(edits.borrow().clone(), vec![40]); |
73 | |
74 | Ok(()) |
75 | } |