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
4import { Button } from "std-widgets.slint";
5
6TestCase := Rectangle {
7 property <bool> checked <=> tb.checked;
8
9 tb := Button {
10 width: 100px;
11 height: 100px;
12
13 checkable: true;
14 checked: true;
15 }
16}
17
18/*
19```cpp
20auto handle = TestCase::create();
21const TestCase &instance = *handle;
22assert(instance.get_checked());
23
24// click on button
25slint_testing::send_mouse_click(&instance, 50., 50.);
26assert(!instance.get_checked());
27
28// click on button again
29slint_testing::send_mouse_click(&instance, 50., 50.);
30assert(instance.get_checked());
31
32```
33
34
35```rust
36let instance = TestCase::new().unwrap();
37assert!(instance.get_checked());
38
39// click on button
40slint_testing::send_mouse_click(&instance, 50., 50.);
41assert!(!instance.get_checked());
42
43// click on button again
44slint_testing::send_mouse_click(&instance, 50., 50.);
45assert!(instance.get_checked());
46
47```
48
49```js
50var instance = new slint.TestCase();
51assert.equal(instance.checked, true);
52
53// click on button
54slintlib.private_api.send_mouse_click(instance, 50., 50.);
55assert.equal(instance.checked, false);
56
57// click on button
58slintlib.private_api.send_mouse_click(instance, 50., 50.);
59assert.equal(instance.checked, true);
60```
61*/
62