1 | #![allow (deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/globals"# ] |
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 Glob := { |
6 | property <int> a_alias <=> a; |
7 | property <int> a: 3; |
8 | property <int> b: a + 3; |
9 | |
10 | } |
11 | |
12 | TestCase := Rectangle { |
13 | callback set_a(int); |
14 | set_a(a) => { Glob.a_alias = a; } |
15 | property <int> value1: Glob.b; |
16 | property <bool> test: value1 == 3+3; |
17 | } |
18 | |
19 | /* |
20 | ```rust |
21 | let instance = TestCase::new().unwrap(); |
22 | assert_eq!(instance.get_value1(), 3+3); |
23 | instance.invoke_set_a(4); |
24 | assert_eq!(instance.get_value1(), 4+3); |
25 | ``` |
26 | |
27 | ```cpp |
28 | auto handle = TestCase::create(); |
29 | const TestCase &instance = *handle; |
30 | assert_eq(instance.get_value1(), 3+3); |
31 | instance.invoke_set_a(4); |
32 | assert_eq(instance.get_value1(), 4+3); |
33 | ``` |
34 | |
35 | ```js |
36 | let instance = new slint.TestCase({}); |
37 | assert.equal(instance.value1, 3+3); |
38 | instance.set_a(4); |
39 | assert.equal(instance.value1, 4+3); |
40 | ``` |
41 | |
42 | */ |
43 | } |
44 | |
45 | #[test ] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> { |
46 | use i_slint_backend_testing as slint_testing; |
47 | slint_testing::init(); |
48 | let instance = TestCase::new().unwrap(); |
49 | assert_eq!(instance.get_value1(), 3+3); |
50 | instance.invoke_set_a(4); |
51 | assert_eq!(instance.get_value1(), 4+3); |
52 | Ok(()) |
53 | } |