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
5TestCase := 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
27auto handle = TestCase::create();
28const TestCase &instance = *handle;
29assert(instance.get_test());
30slint_testing::send_mouse_click(&instance, 50., 50.);
31assert_eq(instance.get_niceness(), 34);
32
33instance.set_niceness(-1);
34assert(!instance.get_test());
35slint_testing::send_mouse_click(&instance, 50., 50.);
36assert_eq(instance.get_niceness(), -1);
37
38```
39
40
41```rust
42let instance = TestCase::new().unwrap();
43assert!(instance.get_test());
44slint_testing::send_mouse_click(&instance, 50., 50.);
45assert_eq!(instance.get_niceness(), 34);
46
47instance.set_niceness(-1);
48assert!(!instance.get_test());
49slint_testing::send_mouse_click(&instance, 50., 50.);
50assert_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}