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 | |
7 | TestCase := 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 |
31 | auto handle = TestCase::create(); |
32 | const TestCase &instance = *handle; |
33 | |
34 | assert_eq(instance.get_creation_count(), 0); |
35 | assert_eq(instance.get_test_height(), 0.); |
36 | assert_eq(instance.get_creation_count(), 0); |
37 | instance.set_repeater_count(2); |
38 | assert_eq(instance.get_test_height(), 20.); |
39 | assert_eq(instance.get_creation_count(), 2); |
40 | ``` |
41 | |
42 | |
43 | ```rust |
44 | let instance = TestCase::new().unwrap(); |
45 | |
46 | assert_eq!(instance.get_creation_count(), 0); |
47 | assert_eq!(instance.get_test_height(), 0.); |
48 | assert_eq!(instance.get_creation_count(), 0); |
49 | instance.set_repeater_count(2); |
50 | assert_eq!(instance.get_test_height(), 20.); |
51 | assert_eq!(instance.get_creation_count(), 2); |
52 | ``` |
53 | |
54 | ```js |
55 | var instance = new slint.TestCase(); |
56 | |
57 | assert.equal(instance.creation_count, 0); |
58 | assert.equal(instance.test_height, 0.); |
59 | assert.equal(instance.creation_count, 0); |
60 | instance.repeater_count = 2; |
61 | assert.equal(instance.test_height, 20.); |
62 | assert.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 | } |