gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 88Markdown 11TOML 91926 Definitions

⎇ 0.1.x tests/generated/flex_grow_root_minimized.rs Rust · 76 lines · 3.1 KB History Who touched what raw

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

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