1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/properties"# ] |
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 | TestCase := Window { |
6 | width: 100px; |
7 | height: 100px; |
8 | property<int> niceness: 33; |
9 | greeting := TouchArea { |
10 | clicked => { root.niceness += 1; } |
11 | t:= Text { |
12 | text: "Hello world" ; |
13 | } |
14 | |
15 | states [ |
16 | rude when root.niceness <= 0: {visible: false;} |
17 | mannered when root.niceness > 100: {t.text: "Hello, dearest world" ; t.font-size: 32px;} |
18 | ] |
19 | } |
20 | |
21 | property <bool> test: greeting.visible; |
22 | } |
23 | |
24 | |
25 | /* |
26 | ```cpp |
27 | auto handle = TestCase::create(); |
28 | const TestCase &instance = *handle; |
29 | assert(instance.get_test()); |
30 | slint_testing::send_mouse_click(&instance, 50., 50.); |
31 | assert_eq(instance.get_niceness(), 34); |
32 | |
33 | instance.set_niceness(-1); |
34 | assert(!instance.get_test()); |
35 | slint_testing::send_mouse_click(&instance, 50., 50.); |
36 | assert_eq(instance.get_niceness(), -1); |
37 | |
38 | ``` |
39 | |
40 | |
41 | ```rust |
42 | let instance = TestCase::new().unwrap(); |
43 | assert!(instance.get_test()); |
44 | slint_testing::send_mouse_click(&instance, 50., 50.); |
45 | assert_eq!(instance.get_niceness(), 34); |
46 | |
47 | instance.set_niceness(-1); |
48 | assert!(!instance.get_test()); |
49 | slint_testing::send_mouse_click(&instance, 50., 50.); |
50 | assert_eq!(instance.get_niceness(), -1); |
51 | ``` |
52 | |
53 | |
54 | */ |
55 | } |
56 | |
57 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
58 | use i_slint_backend_testing as slint_testing; |
59 | slint_testing::init(); |
60 | let instance = TestCase::new().unwrap(); |
61 | assert!(instance.get_test()); |
62 | slint_testing::send_mouse_click(&instance, x:50., y:50.); |
63 | assert_eq!(instance.get_niceness(), 34); |
64 | |
65 | instance.set_niceness(-1); |
66 | assert!(!instance.get_test()); |
67 | slint_testing::send_mouse_click(&instance, x:50., y:50.); |
68 | assert_eq!(instance.get_niceness(), -1); |
69 | Ok(()) |
70 | } |