gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 89Markdown 11TOML 91930 Sutichaykuna

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/flex_grow_height_maximized.rs Rust · 67 siq'ikuna · 2.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

update tests and benchmarks to use new api 1f8c44154 · Emil Sjölander ·

1#[test]
2fn flex_grow_height_maximized() {
3    let layout = stretch::node::Node::new(
4        stretch::style::Style {
5            flex_direction: stretch::style::FlexDirection::Column,
6            size: stretch::geometry::Size {
7                width: stretch::style::Dimension::Points(100f32),
8                height: stretch::style::Dimension::Points(500f32),
9                ..Default::default()
10            },
11            ..Default::default()
12        },
13        vec![&stretch::node::Node::new(
14            stretch::style::Style {
15                flex_direction: stretch::style::FlexDirection::Column,
16                flex_grow: 1f32,
17                min_size: stretch::geometry::Size {
18                    height: stretch::style::Dimension::Points(100f32),
19                    ..Default::default()
20                },
21                max_size: stretch::geometry::Size {
22                    height: stretch::style::Dimension::Points(500f32),
23                    ..Default::default()
24                },
25                ..Default::default()
26            },
27            vec![
28                &stretch::node::Node::new(
29                    stretch::style::Style {
30                        flex_grow: 1f32,
31                        flex_basis: stretch::style::Dimension::Points(200f32),
32                        ..Default::default()
33                    },
34                    vec![],
35                ),
36                &stretch::node::Node::new(
37                    stretch::style::Style {
38                        size: stretch::geometry::Size {
39                            height: stretch::style::Dimension::Points(100f32),
40                            ..Default::default()
41                        },
42                        ..Default::default()
43                    },
44                    vec![],
45                ),
46            ],
47        )],
48    )
49    .compute_layout(stretch::geometry::Size::undefined())
50    .unwrap();
51    assert_eq!(layout.size.width, 100f32);
52    assert_eq!(layout.size.height, 500f32);
53    assert_eq!(layout.location.x, 0f32);
54    assert_eq!(layout.location.y, 0f32);
55    assert_eq!(layout.children[0usize].size.width, 100f32);
56    assert_eq!(layout.children[0usize].size.height, 500f32);
57    assert_eq!(layout.children[0usize].location.x, 0f32);
58    assert_eq!(layout.children[0usize].location.y, 0f32);
59    assert_eq!(layout.children[0usize].children[0usize].size.width, 100f32);
60    assert_eq!(layout.children[0usize].children[0usize].size.height, 400f32);
61    assert_eq!(layout.children[0usize].children[0usize].location.x, 0f32);
62    assert_eq!(layout.children[0usize].children[0usize].location.y, 0f32);
63    assert_eq!(layout.children[0usize].children[1usize].size.width, 100f32);
64    assert_eq!(layout.children[0usize].children[1usize].size.height, 100f32);
65    assert_eq!(layout.children[0usize].children[1usize].location.x, 0f32);
66    assert_eq!(layout.children[0usize].children[1usize].location.y, 400f32);
67}