gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definitions

⎇ 0.1.x tests/generated/wrapped_row_within_align_items_flex_end.rs Rust · 68 lines · 2.7 KB History Who touched what raw

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

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