1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/elements"#]
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
5import { Button } from "std-widgets.slint";
6
7TestCase := Rectangle {
8 property <bool> checked <=> tb.checked;
9
10 tb := Button {
11 width: 100px;
12 height: 100px;
13
14 checkable: true;
15 checked: true;
16 }
17}
18
19/*
20```cpp
21auto handle = TestCase::create();
22const TestCase &instance = *handle;
23assert(instance.get_checked());
24
25// click on button
26slint_testing::send_mouse_click(&instance, 50., 50.);
27assert(!instance.get_checked());
28
29// click on button again
30slint_testing::send_mouse_click(&instance, 50., 50.);
31assert(instance.get_checked());
32
33```
34
35
36```rust
37let instance = TestCase::new().unwrap();
38assert!(instance.get_checked());
39
40// click on button
41slint_testing::send_mouse_click(&instance, 50., 50.);
42assert!(!instance.get_checked());
43
44// click on button again
45slint_testing::send_mouse_click(&instance, 50., 50.);
46assert!(instance.get_checked());
47
48```
49
50```js
51var instance = new slint.TestCase();
52assert.equal(instance.checked, true);
53
54// click on button
55slintlib.private_api.send_mouse_click(instance, 50., 50.);
56assert.equal(instance.checked, false);
57
58// click on button
59slintlib.private_api.send_mouse_click(instance, 50., 50.);
60assert.equal(instance.checked, true);
61```
62*/
63}
64
65#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
66 use i_slint_backend_testing as slint_testing;
67 slint_testing::init();
68 let instance = TestCase::new().unwrap();
69 assert!(instance.get_checked());
70
71 // click on button
72 slint_testing::send_mouse_click(&instance, x:50., y:50.);
73 assert!(!instance.get_checked());
74
75 // click on button again
76 slint_testing::send_mouse_click(&instance, x:50., y:50.);
77 assert!(instance.get_checked());
78
79 Ok(())
80}