1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/models"#]
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
5TestCase := Rectangle {
6 property <[int]> foo: [1, 2, 3];
7 property <[int]> bar: [1, 2, 3];
8 property <int> first: foo[0];
9
10 callback do() -> bool;
11 do => {
12 if (first != 1) { return false; }
13 // This makes both property share the same underlying model
14 // Even though they are the same contents, we must make sure that
15 // the model are properly shared and everything that depends on them
16 // gets dirty
17 foo = bar;
18 if (first != 1) { return false; }
19 bar[0] = 42;
20 if (first != 42) { return false; }
21 return true;
22 }
23
24 property <bool> test: do();
25}
26
27/*
28```cpp
29auto handle = TestCase::create();
30const TestCase &instance = *handle;
31assert(instance.invoke_do());
32```
33
34
35```rust
36let instance = TestCase::new().unwrap();
37assert!(instance.invoke_do());
38```
39
40```js
41var instance = new slint.TestCase({});
42assert(instance.do());
43```
44*/
45}
46
47#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
48 use i_slint_backend_testing as slint_testing;
49 slint_testing::init();
50 let instance = TestCase::new().unwrap();
51 assert!(instance.invoke_do());
52 Ok(())
53}