tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 88Markdown 11TOML 91926 Sutichaykuna

⎇ 0.2.x tests/generated/gap_row_gap_align_items_stretch.rs Rust · 106 siq'ikuna · 4.4 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

1#[test]
2fn gap_row_gap_align_items_stretch() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
8                ..Default::default()
9            },
10            &[],
11        )
12        .unwrap();
13    let node1 = taffy
14        .new_with_children(
15            taffy::style::Style {
16                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node2 = taffy
23        .new_with_children(
24            taffy::style::Style {
25                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
26                ..Default::default()
27            },
28            &[],
29        )
30        .unwrap();
31    let node3 = taffy
32        .new_with_children(
33            taffy::style::Style {
34                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
35                ..Default::default()
36            },
37            &[],
38        )
39        .unwrap();
40    let node4 = taffy
41        .new_with_children(
42            taffy::style::Style {
43                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
44                ..Default::default()
45            },
46            &[],
47        )
48        .unwrap();
49    let node5 = taffy
50        .new_with_children(
51            taffy::style::Style {
52                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), ..Default::default() },
53                ..Default::default()
54            },
55            &[],
56        )
57        .unwrap();
58    let node = taffy
59        .new_with_children(
60            taffy::style::Style {
61                flex_wrap: taffy::style::FlexWrap::Wrap,
62                gap: taffy::geometry::Size {
63                    width: taffy::style::Dimension::Points(10f32),
64                    height: taffy::style::Dimension::Points(20f32),
65                    ..Default::default()
66                },
67                size: taffy::geometry::Size {
68                    width: taffy::style::Dimension::Points(100f32),
69                    height: taffy::style::Dimension::Points(200f32),
70                    ..Default::default()
71                },
72                ..Default::default()
73            },
74            &[node0, node1, node2, node3, node4, node5],
75        )
76        .unwrap();
77    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
78    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
79    assert_eq!(taffy.layout(node).unwrap().size.height, 200f32);
80    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
81    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
82    assert_eq!(taffy.layout(node0).unwrap().size.width, 20f32);
83    assert_eq!(taffy.layout(node0).unwrap().size.height, 90f32);
84    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
85    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
86    assert_eq!(taffy.layout(node1).unwrap().size.width, 20f32);
87    assert_eq!(taffy.layout(node1).unwrap().size.height, 90f32);
88    assert_eq!(taffy.layout(node1).unwrap().location.x, 30f32);
89    assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
90    assert_eq!(taffy.layout(node2).unwrap().size.width, 20f32);
91    assert_eq!(taffy.layout(node2).unwrap().size.height, 90f32);
92    assert_eq!(taffy.layout(node2).unwrap().location.x, 60f32);
93    assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32);
94    assert_eq!(taffy.layout(node3).unwrap().size.width, 20f32);
95    assert_eq!(taffy.layout(node3).unwrap().size.height, 90f32);
96    assert_eq!(taffy.layout(node3).unwrap().location.x, 0f32);
97    assert_eq!(taffy.layout(node3).unwrap().location.y, 110f32);
98    assert_eq!(taffy.layout(node4).unwrap().size.width, 20f32);
99    assert_eq!(taffy.layout(node4).unwrap().size.height, 90f32);
100    assert_eq!(taffy.layout(node4).unwrap().location.x, 30f32);
101    assert_eq!(taffy.layout(node4).unwrap().location.y, 110f32);
102    assert_eq!(taffy.layout(node5).unwrap().size.width, 20f32);
103    assert_eq!(taffy.layout(node5).unwrap().size.height, 90f32);
104    assert_eq!(taffy.layout(node5).unwrap().location.x, 60f32);
105    assert_eq!(taffy.layout(node5).unwrap().location.y, 110f32);
106}