1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/bindings"#]
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
5component Buggy {
6 in-out property<string> magic: "Nope";
7 property<bool> condition: false;
8
9 public function change_condition() {
10 condition = !condition;
11 }
12
13 HorizontalLayout {
14 if root.condition: TouchArea {
15 property <string> innermagic <=> root.magic;
16 clicked => { self.innermagic = "Hello"; }
17 horizontal-stretch: 1;
18 }
19
20 Rectangle {
21 background: red;
22 TouchArea {
23 clicked => { change-condition() }
24 }
25 }
26 }
27}
28
29
30component TestCase {
31 width: 300px;
32 height: 100px;
33
34 public function change_condition() {
35 b.change-condition();
36 }
37
38 b := Buggy {
39 width: 100%;
40 height: 100%;
41 magic: "Hi";
42 }
43
44 out property <string> magic: b.magic;
45}
46
47
48/*
49
50```rust
51let instance = TestCase::new().unwrap();
52assert_eq!(instance.get_magic(), slint::SharedString::from("Hi"));
53instance.invoke_change_condition();
54instance.invoke_change_condition();
55instance.invoke_change_condition();
56assert_eq!(instance.get_magic(), slint::SharedString::from("Hi"));
57slint_testing::send_mouse_click(&instance, 10., 10.);
58assert_eq!(instance.get_magic(), slint::SharedString::from("Hello"));
59```
60
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_eq!(instance.get_magic(), slint::SharedString::from("Hi"));
70 instance.invoke_change_condition();
71 instance.invoke_change_condition();
72 instance.invoke_change_condition();
73 assert_eq!(instance.get_magic(), slint::SharedString::from("Hi"));
74 slint_testing::send_mouse_click(&instance, x:10., y:10.);
75 assert_eq!(instance.get_magic(), slint::SharedString::from("Hello"));
76 Ok(())
77}