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
5
6
7TestCase := Rectangle {
8 width: 100phx;
9 height: 100phx;
10
11 property <int> creation-count: 0;
12
13 property <length> test-height: preferred-height;
14
15 property <int> repeater-count: -10;
16
17 VerticalLayout {
18 for _ in repeater-count: Rectangle {
19 preferred-height: 10px;
20 init => {
21 creation-count += 1;
22 }
23 }
24 }
25
26}
27
28
29/*
30```cpp
31auto handle = TestCase::create();
32const TestCase &instance = *handle;
33
34assert_eq(instance.get_creation_count(), 0);
35assert_eq(instance.get_test_height(), 0.);
36assert_eq(instance.get_creation_count(), 0);
37instance.set_repeater_count(2);
38assert_eq(instance.get_test_height(), 20.);
39assert_eq(instance.get_creation_count(), 2);
40```
41
42
43```rust
44let instance = TestCase::new().unwrap();
45
46assert_eq!(instance.get_creation_count(), 0);
47assert_eq!(instance.get_test_height(), 0.);
48assert_eq!(instance.get_creation_count(), 0);
49instance.set_repeater_count(2);
50assert_eq!(instance.get_test_height(), 20.);
51assert_eq!(instance.get_creation_count(), 2);
52```
53
54```js
55var instance = new slint.TestCase();
56
57assert.equal(instance.creation_count, 0);
58assert.equal(instance.test_height, 0.);
59assert.equal(instance.creation_count, 0);
60instance.repeater_count = 2;
61assert.equal(instance.test_height, 20.);
62assert.equal(instance.creation_count, 2);
63```
64*/
65}
66
67#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
68 use i_slint_backend_testing as slint_testing;
69 slint_testing::init();
70 let instance = TestCase::new().unwrap();
71
72 assert_eq!(instance.get_creation_count(), 0);
73 assert_eq!(instance.get_test_height(), 0.);
74 assert_eq!(instance.get_creation_count(), 0);
75 instance.set_repeater_count(2);
76 assert_eq!(instance.get_test_height(), 20.);
77 assert_eq!(instance.get_creation_count(), 2);
78 Ok(())
79}