gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81377 Sutichaykuna

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/flex_wrap_wrap_to_child_height.rs Rust · 69 siq'ikuna · 3.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

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