1#![allow(deprecated)]slint::slint!{#[include_path=r#"/input/slint/tests/driver/driverlib/../../cases/layout"#]
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 := Window {
6 width: 200phx;
7 height: 500phx;
8
9 layout := GridLayout {
10 spacing: 0phx;
11 padding: 0phx;
12 Row { }
13 Row {
14 rect1 := Rectangle { background: red; }
15 rect2 := Rectangle { background: orange; }
16 }
17 rect3 := Rectangle { background: blue; }
18 rect4 := Rectangle { background: yellow; }
19 Row {
20 rect5 := Rectangle { background: green; }
21 rect6 := Rectangle { background: pink; }
22 }
23 Row { }
24 rect7 := Rectangle { background: gray; }
25 rect8 := Rectangle { background: cyan; }
26 Row { }
27 rect9 := Rectangle { background: magenta; }
28 rect10 := Rectangle { background: purple; }
29 }
30
31 // there should be 5 rows
32 property <bool> size_ok:
33 rect1.width == 100phx && rect1.height == 100phx &&
34 rect2.width == 100phx && rect2.height == 100phx &&
35 rect3.width == 100phx && rect3.height == 100phx &&
36 rect4.width == 100phx && rect4.height == 100phx &&
37 rect5.width == 100phx && rect5.height == 100phx &&
38 rect6.width == 100phx && rect6.height == 100phx &&
39 rect7.width == 100phx && rect7.height == 100phx &&
40 rect8.width == 100phx && rect8.height == 100phx &&
41 rect9.width == 100phx && rect9.height == 100phx &&
42 rect10.width == 100phx && rect10.height == 100phx;
43 property <bool> x_ok:
44 rect1.x == 0phx && rect2.x == 100phx &&
45 rect3.x == 0phx && rect4.x == 100phx &&
46 rect5.x == 0phx && rect6.x == 100phx &&
47 rect7.x == 0phx && rect8.x == 100phx &&
48 rect9.x == 0phx && rect10.x == 100phx;
49
50 property <bool> y_ok:
51 rect1.y == 0phx && rect2.y == 0phx &&
52 rect3.y == 100phx && rect4.y == 100phx &&
53 rect5.y == 200phx && rect6.y == 200phx &&
54 rect7.y == 300phx && rect8.y == 300phx &&
55 rect9.y == 400phx && rect9.y == 400phx;
56}
57
58/*
59
60```cpp
61auto handle = TestCase::create();
62const TestCase &instance = *handle;
63assert(instance.get_size_ok());
64assert(instance.get_x_ok());
65assert(instance.get_y_ok());
66```
67
68
69```rust
70let instance = TestCase::new().unwrap();
71assert!(instance.get_size_ok());
72assert!(instance.get_x_ok());
73assert!(instance.get_y_ok());
74```
75
76```js
77var instance = new slint.TestCase();
78slintlib.private_api.send_mouse_click(instance, 5., 5.);
79assert(instance.size_ok);
80assert(instance.x_ok);
81assert(instance.y_ok);
82```
83*/
84}
85
86#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
87 use i_slint_backend_testing as slint_testing;
88 slint_testing::init();
89 let instance = TestCase::new().unwrap();
90 assert!(instance.get_size_ok());
91 assert!(instance.get_x_ok());
92 assert!(instance.get_y_ok());
93 Ok(())
94}