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
5export component TestCase inherits Window {
6 width: 200px;
7 min-height: 300px;
8 VerticalLayout {
9 HorizontalLayout {
10 green := Rectangle {
11 background: Colors.green;
12 width: 100px;
13 }
14 red := Rectangle { background: Colors.red; }
15 }
16 Rectangle { background: orange; }
17 }
18
19 out property <length> win_w: root.width;
20 out property <length> win_h: root.height;
21 out property <length> green_w: green.width;
22 out property <length> red_w: red.width;
23
24
25 out property <bool> test: root.min-height == 300px && root.width == 200px && green.width == 100px && red.width == 100px;
26}
27
28/*
29
30```cpp
31auto handle = TestCase::create();
32TestCase &instance = *handle;
33instance.show();
34assert(instance.get_test());
35auto size = instance.window().size();
36assert(size == slint::PhysicalSize({200, 300}));
37assert_eq(instance.get_win_h(), 300.);
38assert_eq(instance.get_win_w(), 200.);
39assert_eq(instance.get_green_w(), 100.);
40assert_eq(instance.get_red_w(), 100.);
41instance.window().set_size(slint::PhysicalSize({150, 150}));
42assert_eq(instance.get_win_h(), 150.); // this didn't have a fixed sized, so the size follow (FIXME: it probably shouldn't)
43assert_eq(instance.get_win_w(), 200.); // but because we have a fixed sized, the geometry don't change
44assert_eq(instance.get_green_w(), 100.);
45assert_eq(instance.get_red_w(), 100.);
46
47```
48
49
50```rust
51let instance = TestCase::new().unwrap();
52instance.show().unwrap();
53assert!(instance.get_test());
54let size = instance.window().size();
55assert_eq!(size, slint::PhysicalSize::new(200, 300));
56assert_eq!(instance.get_win_h(), 300.);
57assert_eq!(instance.get_win_w(), 200.);
58assert_eq!(instance.get_green_w(), 100.);
59assert_eq!(instance.get_red_w(), 100.);
60instance.window().set_size(slint::PhysicalSize::new(150, 150));
61assert_eq!(instance.get_win_h(), 150.); // this didn't have a fixed sized, so the size follow (FIXME: it probably shouldn't)
62assert_eq!(instance.get_win_w(), 200.); // but because we have a fixed sized, the geometry don't change
63assert_eq!(instance.get_green_w(), 100.);
64assert_eq!(instance.get_red_w(), 100.);
65```
66
67
68*/
69}
70
71#[test] fn t_0() -> std::result::Result<(), std::boxed::Box<dyn std::error::Error>> {
72 use i_slint_backend_testing as slint_testing;
73 slint_testing::init();
74 let instance = TestCase::new().unwrap();
75 instance.show().unwrap();
76 assert!(instance.get_test());
77 let size = instance.window().size();
78 assert_eq!(size, slint::PhysicalSize::new(200, 300));
79 assert_eq!(instance.get_win_h(), 300.);
80 assert_eq!(instance.get_win_w(), 200.);
81 assert_eq!(instance.get_green_w(), 100.);
82 assert_eq!(instance.get_red_w(), 100.);
83 instance.window().set_size(slint::PhysicalSize::new(width:150, height:150));
84 assert_eq!(instance.get_win_h(), 150.); // this didn't have a fixed sized, so the size follow (FIXME: it probably shouldn't)
85 assert_eq!(instance.get_win_w(), 200.); // but because we have a fixed sized, the geometry don't change
86 assert_eq!(instance.get_green_w(), 100.);
87 assert_eq!(instance.get_red_w(), 100.);
88 Ok(())
89}