1// Copyright © SixtyFPS GmbH <info@slint.dev>
2// SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-Slint-Royalty-free-2.0 OR LicenseRef-Slint-Software-3.0
3
4TestCase := Window {
5 width: 100px;
6 height: 100px;
7 property<int> niceness: 33;
8 greeting := TouchArea {
9 clicked => { root.niceness += 1; }
10 t:= Text {
11 text: "Hello world";
12 }
13
14 states [
15 rude when root.niceness <= 0: {visible: false;}
16 mannered when root.niceness > 100: {t.text: "Hello, dearest world"; t.font-size: 32px;}
17 ]
18 }
19
20 property <bool> test: greeting.visible;
21}
22
23
24/*
25```cpp
26auto handle = TestCase::create();
27const TestCase &instance = *handle;
28assert(instance.get_test());
29slint_testing::send_mouse_click(&instance, 50., 50.);
30assert_eq(instance.get_niceness(), 34);
31
32instance.set_niceness(-1);
33assert(!instance.get_test());
34slint_testing::send_mouse_click(&instance, 50., 50.);
35assert_eq(instance.get_niceness(), -1);
36
37```
38
39
40```rust
41let instance = TestCase::new().unwrap();
42assert!(instance.get_test());
43slint_testing::send_mouse_click(&instance, 50., 50.);
44assert_eq!(instance.get_niceness(), 34);
45
46instance.set_niceness(-1);
47assert!(!instance.get_test());
48slint_testing::send_mouse_click(&instance, 50., 50.);
49assert_eq!(instance.get_niceness(), -1);
50```
51
52
53*/
54