tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Definiciones

⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f tests/generated/flex/wrap_reverse_row_align_content_flex_start.rs Rust · 213 líneas · 11.2 KB Historia Quién tocó qué crudo

Use tagged pointer to represent size/length values (#769) afa6437b0 · Nico Burns ·

1#[test]
2#[allow(non_snake_case)]
3fn wrap_reverse_row_align_content_flex_start__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node0 = taffy
8        .new_leaf(taffy::style::Style {
9            size: taffy::geometry::Size {
10                width: taffy::style::Dimension::from_length(30f32),
11                height: taffy::style::Dimension::from_length(10f32),
12            },
13            ..Default::default()
14        })
15        .unwrap();
16    let node1 = taffy
17        .new_leaf(taffy::style::Style {
18            size: taffy::geometry::Size {
19                width: taffy::style::Dimension::from_length(30f32),
20                height: taffy::style::Dimension::from_length(20f32),
21            },
22            ..Default::default()
23        })
24        .unwrap();
25    let node2 = taffy
26        .new_leaf(taffy::style::Style {
27            size: taffy::geometry::Size {
28                width: taffy::style::Dimension::from_length(30f32),
29                height: taffy::style::Dimension::from_length(30f32),
30            },
31            ..Default::default()
32        })
33        .unwrap();
34    let node3 = taffy
35        .new_leaf(taffy::style::Style {
36            size: taffy::geometry::Size {
37                width: taffy::style::Dimension::from_length(30f32),
38                height: taffy::style::Dimension::from_length(40f32),
39            },
40            ..Default::default()
41        })
42        .unwrap();
43    let node4 = taffy
44        .new_leaf(taffy::style::Style {
45            size: taffy::geometry::Size {
46                width: taffy::style::Dimension::from_length(30f32),
47                height: taffy::style::Dimension::from_length(50f32),
48            },
49            ..Default::default()
50        })
51        .unwrap();
52    let node = taffy
53        .new_with_children(
54            taffy::style::Style {
55                flex_wrap: taffy::style::FlexWrap::WrapReverse,
56                align_content: Some(taffy::style::AlignContent::FlexStart),
57                size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
58                ..Default::default()
59            },
60            &[node0, node1, node2, node3, node4],
61        )
62        .unwrap();
63    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
64    println!("\nComputed tree:");
65    taffy.print_tree(node);
66    println!();
67    let layout = taffy.layout(node).unwrap();
68    let Layout { size, location, .. } = layout;
69    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
70    assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height);
71    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
72    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
73    let layout = taffy.layout(node0).unwrap();
74    let Layout { size, location, .. } = layout;
75    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
76    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
77    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
78    assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y);
79    let layout = taffy.layout(node1).unwrap();
80    let Layout { size, location, .. } = layout;
81    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
82    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
83    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
84    assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y);
85    let layout = taffy.layout(node2).unwrap();
86    let Layout { size, location, .. } = layout;
87    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width);
88    assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height);
89    assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
90    assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y);
91    let layout = taffy.layout(node3).unwrap();
92    let Layout { size, location, .. } = layout;
93    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width);
94    assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height);
95    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
96    assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y);
97    let layout = taffy.layout(node4).unwrap();
98    let Layout { size, location, .. } = layout;
99    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width);
100    assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height);
101    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
102    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y);
103}
104
105#[test]
106#[allow(non_snake_case)]
107fn wrap_reverse_row_align_content_flex_start__content_box() {
108    #[allow(unused_imports)]
109    use taffy::{prelude::*, Layout};
110    let mut taffy = crate::new_test_tree();
111    let node0 = taffy
112        .new_leaf(taffy::style::Style {
113            box_sizing: taffy::style::BoxSizing::ContentBox,
114            size: taffy::geometry::Size {
115                width: taffy::style::Dimension::from_length(30f32),
116                height: taffy::style::Dimension::from_length(10f32),
117            },
118            ..Default::default()
119        })
120        .unwrap();
121    let node1 = taffy
122        .new_leaf(taffy::style::Style {
123            box_sizing: taffy::style::BoxSizing::ContentBox,
124            size: taffy::geometry::Size {
125                width: taffy::style::Dimension::from_length(30f32),
126                height: taffy::style::Dimension::from_length(20f32),
127            },
128            ..Default::default()
129        })
130        .unwrap();
131    let node2 = taffy
132        .new_leaf(taffy::style::Style {
133            box_sizing: taffy::style::BoxSizing::ContentBox,
134            size: taffy::geometry::Size {
135                width: taffy::style::Dimension::from_length(30f32),
136                height: taffy::style::Dimension::from_length(30f32),
137            },
138            ..Default::default()
139        })
140        .unwrap();
141    let node3 = taffy
142        .new_leaf(taffy::style::Style {
143            box_sizing: taffy::style::BoxSizing::ContentBox,
144            size: taffy::geometry::Size {
145                width: taffy::style::Dimension::from_length(30f32),
146                height: taffy::style::Dimension::from_length(40f32),
147            },
148            ..Default::default()
149        })
150        .unwrap();
151    let node4 = taffy
152        .new_leaf(taffy::style::Style {
153            box_sizing: taffy::style::BoxSizing::ContentBox,
154            size: taffy::geometry::Size {
155                width: taffy::style::Dimension::from_length(30f32),
156                height: taffy::style::Dimension::from_length(50f32),
157            },
158            ..Default::default()
159        })
160        .unwrap();
161    let node = taffy
162        .new_with_children(
163            taffy::style::Style {
164                box_sizing: taffy::style::BoxSizing::ContentBox,
165                flex_wrap: taffy::style::FlexWrap::WrapReverse,
166                align_content: Some(taffy::style::AlignContent::FlexStart),
167                size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
168                ..Default::default()
169            },
170            &[node0, node1, node2, node3, node4],
171        )
172        .unwrap();
173    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
174    println!("\nComputed tree:");
175    taffy.print_tree(node);
176    println!();
177    let layout = taffy.layout(node).unwrap();
178    let Layout { size, location, .. } = layout;
179    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
180    assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node, 80f32, size.height);
181    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
182    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
183    let layout = taffy.layout(node0).unwrap();
184    let Layout { size, location, .. } = layout;
185    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
186    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
187    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
188    assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node0, 70f32, location.y);
189    let layout = taffy.layout(node1).unwrap();
190    let Layout { size, location, .. } = layout;
191    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
192    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
193    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
194    assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node1, 60f32, location.y);
195    let layout = taffy.layout(node2).unwrap();
196    let Layout { size, location, .. } = layout;
197    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width);
198    assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height);
199    assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
200    assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node2, 50f32, location.y);
201    let layout = taffy.layout(node3).unwrap();
202    let Layout { size, location, .. } = layout;
203    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width);
204    assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height);
205    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
206    assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y);
207    let layout = taffy.layout(node4).unwrap();
208    let Layout { size, location, .. } = layout;
209    assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node4, 30f32, size.width);
210    assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height);
211    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
212    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y);
213}