⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/align_content_space_around_wrapped.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_content_space_around_wrapped__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(50f32),
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(50f32),
20 height: taffy::style::Dimension::from_length(10f32),
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(50f32),
29 height: taffy::style::Dimension::from_length(10f32),
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(50f32),
38 height: taffy::style::Dimension::from_length(10f32),
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(50f32),
47 height: taffy::style::Dimension::from_length(10f32),
48 },
49 ..Default::default()
50 })
51 .unwrap();
52 let node5 = taffy
53 .new_leaf(taffy::style::Style {
54 size: taffy::geometry::Size {
55 width: taffy::style::Dimension::from_length(50f32),
56 height: taffy::style::Dimension::from_length(10f32),
57 },
58 ..Default::default()
59 })
60 .unwrap();
61 let node = taffy
62 .new_with_children(
63 taffy::style::Style {
64 flex_wrap: taffy::style::FlexWrap::Wrap,
65 align_content: Some(taffy::style::AlignContent::SpaceAround),
66 size: taffy::geometry::Size {
67 width: taffy::style::Dimension::from_length(100f32),
68 height: taffy::style::Dimension::from_length(100f32),
69 },
70 ..Default::default()
71 },
72 &[node0, node1, node2, node3, node4, node5],
73 )
74 .unwrap();
75 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
76 println!("\nComputed tree:");
77 taffy.print_tree(node);
78 println!();
79 let layout = taffy.layout(node).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
82 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
85 let layout = taffy.layout(node0).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
88 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
89 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
90 assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y);
91 let layout = taffy.layout(node1).unwrap();
92 let Layout { size, location, .. } = layout;
93 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
94 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
95 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
96 assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y);
97 let layout = taffy.layout(node2).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
100 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
102 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y);
103 let layout = taffy.layout(node3).unwrap();
104 let Layout { size, location, .. } = layout;
105 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
106 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
107 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x);
108 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y);
109 let layout = taffy.layout(node4).unwrap();
110 let Layout { size, location, .. } = layout;
111 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
112 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height);
113 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
114 assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node4, 78f32, location.y);
115 let layout = taffy.layout(node5).unwrap();
116 let Layout { size, location, .. } = layout;
117 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width);
118 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height);
119 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x);
120 assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node5, 78f32, location.y);
121}
122
123#[test]
124#[allow(non_snake_case)]
125fn align_content_space_around_wrapped__content_box() {
126 #[allow(unused_imports)]
127 use taffy::{prelude::*, Layout};
128 let mut taffy = crate::new_test_tree();
129 let node0 = taffy
130 .new_leaf(taffy::style::Style {
131 box_sizing: taffy::style::BoxSizing::ContentBox,
132 size: taffy::geometry::Size {
133 width: taffy::style::Dimension::from_length(50f32),
134 height: taffy::style::Dimension::from_length(10f32),
135 },
136 ..Default::default()
137 })
138 .unwrap();
139 let node1 = taffy
140 .new_leaf(taffy::style::Style {
141 box_sizing: taffy::style::BoxSizing::ContentBox,
142 size: taffy::geometry::Size {
143 width: taffy::style::Dimension::from_length(50f32),
144 height: taffy::style::Dimension::from_length(10f32),
145 },
146 ..Default::default()
147 })
148 .unwrap();
149 let node2 = taffy
150 .new_leaf(taffy::style::Style {
151 box_sizing: taffy::style::BoxSizing::ContentBox,
152 size: taffy::geometry::Size {
153 width: taffy::style::Dimension::from_length(50f32),
154 height: taffy::style::Dimension::from_length(10f32),
155 },
156 ..Default::default()
157 })
158 .unwrap();
159 let node3 = taffy
160 .new_leaf(taffy::style::Style {
161 box_sizing: taffy::style::BoxSizing::ContentBox,
162 size: taffy::geometry::Size {
163 width: taffy::style::Dimension::from_length(50f32),
164 height: taffy::style::Dimension::from_length(10f32),
165 },
166 ..Default::default()
167 })
168 .unwrap();
169 let node4 = taffy
170 .new_leaf(taffy::style::Style {
171 box_sizing: taffy::style::BoxSizing::ContentBox,
172 size: taffy::geometry::Size {
173 width: taffy::style::Dimension::from_length(50f32),
174 height: taffy::style::Dimension::from_length(10f32),
175 },
176 ..Default::default()
177 })
178 .unwrap();
179 let node5 = taffy
180 .new_leaf(taffy::style::Style {
181 box_sizing: taffy::style::BoxSizing::ContentBox,
182 size: taffy::geometry::Size {
183 width: taffy::style::Dimension::from_length(50f32),
184 height: taffy::style::Dimension::from_length(10f32),
185 },
186 ..Default::default()
187 })
188 .unwrap();
189 let node = taffy
190 .new_with_children(
191 taffy::style::Style {
192 box_sizing: taffy::style::BoxSizing::ContentBox,
193 flex_wrap: taffy::style::FlexWrap::Wrap,
194 align_content: Some(taffy::style::AlignContent::SpaceAround),
195 size: taffy::geometry::Size {
196 width: taffy::style::Dimension::from_length(100f32),
197 height: taffy::style::Dimension::from_length(100f32),
198 },
199 ..Default::default()
200 },
201 &[node0, node1, node2, node3, node4, node5],
202 )
203 .unwrap();
204 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
205 println!("\nComputed tree:");
206 taffy.print_tree(node);
207 println!();
208 let layout = taffy.layout(node).unwrap();
209 let Layout { size, location, .. } = layout;
210 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
211 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
212 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
213 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
214 let layout = taffy.layout(node0).unwrap();
215 let Layout { size, location, .. } = layout;
216 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
217 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
218 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
219 assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node0, 12f32, location.y);
220 let layout = taffy.layout(node1).unwrap();
221 let Layout { size, location, .. } = layout;
222 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
223 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
224 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
225 assert_eq!(location.y, 12f32, "y of node {:?}. Expected {}. Actual {}", node1, 12f32, location.y);
226 let layout = taffy.layout(node2).unwrap();
227 let Layout { size, location, .. } = layout;
228 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
229 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
230 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
231 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y);
232 let layout = taffy.layout(node3).unwrap();
233 let Layout { size, location, .. } = layout;
234 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
235 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
236 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x);
237 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y);
238 let layout = taffy.layout(node4).unwrap();
239 let Layout { size, location, .. } = layout;
240 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
241 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height);
242 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
243 assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node4, 78f32, location.y);
244 let layout = taffy.layout(node5).unwrap();
245 let Layout { size, location, .. } = layout;
246 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node5, 50f32, size.width);
247 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5, 10f32, size.height);
248 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5, 50f32, location.x);
249 assert_eq!(location.y, 78f32, "y of node {:?}. Expected {}. Actual {}", node5, 78f32, location.y);
250}