1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/lookup"# ] |
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 | |
5 | global MyGlobal := { |
6 | property<int> bar: 5; |
7 | property<int> foo: 3; |
8 | callback glob_callback; |
9 | } |
10 | |
11 | Foo := Rectangle { |
12 | property<int> foo_prop: MyGlobal.foo; |
13 | for ha in 3: Rectangle { |
14 | x: (ha + MyGlobal.bar) * 1px; |
15 | } |
16 | } |
17 | |
18 | TestCase := Rectangle { |
19 | |
20 | callback invoke_glob; |
21 | invoke_glob => { |
22 | MyGlobal.glob_callback(); |
23 | } |
24 | Foo {} |
25 | foo := Foo {} |
26 | Foo {} |
27 | property<int> p1: 10 * MyGlobal.bar + 1; |
28 | property<int> p2: foo.foo_prop; |
29 | |
30 | } |
31 | /* |
32 | ```cpp |
33 | auto handle = TestCase::create(); |
34 | const TestCase &instance = *handle; |
35 | assert_eq(instance.get_p1(), 51); |
36 | assert_eq(instance.get_p2(), 3); |
37 | ``` |
38 | |
39 | ```rust |
40 | let instance = TestCase::new().unwrap(); |
41 | assert_eq!(instance.get_p1(), 51); |
42 | assert_eq!(instance.get_p2(), 3); |
43 | ``` |
44 | |
45 | ```js |
46 | var instance = new slint.TestCase({}); |
47 | assert.equal(instance.p1, 51); |
48 | assert.equal(instance.p2, 3); |
49 | ``` |
50 | */ |
51 | } |
52 | |
53 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
54 | use i_slint_backend_testing as slint_testing; |
55 | slint_testing::init(); |
56 | let instance = TestCase::new().unwrap(); |
57 | assert_eq!(instance.get_p1(), 51); |
58 | assert_eq!(instance.get_p2(), 3); |
59 | Ok(()) |
60 | } |