gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Sutichaykuna

⎇ 0.1.x tests/generated/flex_wrap_wrap_to_child_height.rs Rust · 77 siq'ikuna · 3.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

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