gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 500HTML 254C 19JavaScript 81398 Definitions

⎇ ca514f6c8ddc2a934f97170227bbe109223c80b8 tests/generated/align_baseline_child_multiline.rs Rust · 118 lines · 4.7 KB History Who touched what raw

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

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