1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/callbacks"#]
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
5global G := {
6 property <string> hello: "hello";
7 function meh(w: string) -> string {
8 return hello + " " + w;
9 }
10}
11
12SubCompo := Rectangle {
13 public pure function hello() -> color { red }
14}
15
16export global PubGlob := {
17 public function beh(a: int, b: int) -> int { a + b + 10 }
18}
19
20TestCase := Rectangle {
21
22 property <int> c: 100000;
23 private property <int> one: 1 + Math.round((x / 1px) - (y / 1px));
24
25 function foo() {}
26 function the_function(a: int, b: int) -> int { foo(); a + b + c + one }
27
28 if true : Rectangle {
29 background: the_function(1, 2) > 3 ? blue: sc.hello();
30 }
31
32 sc := SubCompo {
33
34 }
35
36 public function pub(a: int, b: int) -> int { a + b + c }
37
38 public function set_c(p: int) { c = p }
39
40
41 property <bool> test: the_function(4500, 20) == 104521 && G.meh("world") == "hello world" && sc.hello() == Colors.red;
42}
43
44/*
45```rust
46let instance = TestCase::new().unwrap();
47assert!(instance.get_test());
48assert_eq!(instance.invoke_pub(20, 2), 100022);
49assert_eq!(instance.global::<PubGlob<'_>>().invoke_beh(2, 2), 14);
50```
51
52```cpp
53auto handle = TestCase::create();
54const TestCase &instance = *handle;
55assert(instance.get_test());
56assert_eq(instance.invoke_pub(20, 2), 100022);
57assert_eq(instance.global<PubGlob>().invoke_beh(2, 2), 14);
58```
59
60
61```js
62var instance = new slint.TestCase();
63assert(instance.test);
64// TODO: function call
65```
66*/
67}
68
69#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
70 use i_slint_backend_testing as slint_testing;
71 slint_testing::init();
72 let instance = TestCase::new().unwrap();
73 assert!(instance.get_test());
74 assert_eq!(instance.invoke_pub(20, 2), 100022);
75 assert_eq!(instance.global::<PubGlob<'_>>().invoke_beh(2, 2), 14);
76 Ok(())
77}