⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/multiline_column_max_height.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn multiline_column_max_height__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 flex_shrink: 0f32,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(40f32),
12 height: taffy::style::Dimension::from_length(20f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node1 = taffy
18 .new_leaf(taffy::style::Style {
19 flex_shrink: 0f32,
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::from_length(40f32),
22 height: taffy::style::Dimension::from_length(20f32),
23 },
24 ..Default::default()
25 })
26 .unwrap();
27 let node2 = taffy
28 .new_leaf(taffy::style::Style {
29 flex_shrink: 0f32,
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::from_length(40f32),
32 height: taffy::style::Dimension::from_length(20f32),
33 },
34 ..Default::default()
35 })
36 .unwrap();
37 let node3 = taffy
38 .new_leaf(taffy::style::Style {
39 flex_shrink: 0f32,
40 size: taffy::geometry::Size {
41 width: taffy::style::Dimension::from_length(40f32),
42 height: taffy::style::Dimension::from_length(20f32),
43 },
44 ..Default::default()
45 })
46 .unwrap();
47 let node4 = taffy
48 .new_leaf(taffy::style::Style {
49 flex_shrink: 0f32,
50 size: taffy::geometry::Size {
51 width: taffy::style::Dimension::from_length(40f32),
52 height: taffy::style::Dimension::from_length(20f32),
53 },
54 ..Default::default()
55 })
56 .unwrap();
57 let node5 = taffy
58 .new_leaf(taffy::style::Style {
59 flex_shrink: 0f32,
60 size: taffy::geometry::Size {
61 width: taffy::style::Dimension::from_length(40f32),
62 height: taffy::style::Dimension::from_length(20f32),
63 },
64 ..Default::default()
65 })
66 .unwrap();
67 let node6 = taffy
68 .new_leaf(taffy::style::Style {
69 flex_shrink: 0f32,
70 size: taffy::geometry::Size {
71 width: taffy::style::Dimension::from_length(40f32),
72 height: taffy::style::Dimension::from_length(20f32),
73 },
74 ..Default::default()
75 })
76 .unwrap();
77 let node7 = taffy
78 .new_leaf(taffy::style::Style {
79 flex_shrink: 0f32,
80 size: taffy::geometry::Size {
81 width: taffy::style::Dimension::from_length(40f32),
82 height: taffy::style::Dimension::from_length(20f32),
83 },
84 ..Default::default()
85 })
86 .unwrap();
87 let node8 = taffy
88 .new_leaf(taffy::style::Style {
89 flex_shrink: 0f32,
90 size: taffy::geometry::Size {
91 width: taffy::style::Dimension::from_length(40f32),
92 height: taffy::style::Dimension::from_length(20f32),
93 },
94 ..Default::default()
95 })
96 .unwrap();
97 let node9 = taffy
98 .new_leaf(taffy::style::Style {
99 flex_shrink: 0f32,
100 size: taffy::geometry::Size {
101 width: taffy::style::Dimension::from_length(40f32),
102 height: taffy::style::Dimension::from_length(20f32),
103 },
104 ..Default::default()
105 })
106 .unwrap();
107 let node10 = taffy
108 .new_leaf(taffy::style::Style {
109 flex_shrink: 0f32,
110 size: taffy::geometry::Size {
111 width: taffy::style::Dimension::from_length(40f32),
112 height: taffy::style::Dimension::from_length(20f32),
113 },
114 ..Default::default()
115 })
116 .unwrap();
117 let node11 = taffy
118 .new_leaf(taffy::style::Style {
119 flex_shrink: 0f32,
120 size: taffy::geometry::Size {
121 width: taffy::style::Dimension::from_length(40f32),
122 height: taffy::style::Dimension::from_length(20f32),
123 },
124 ..Default::default()
125 })
126 .unwrap();
127 let node12 = taffy
128 .new_leaf(taffy::style::Style {
129 flex_shrink: 0f32,
130 size: taffy::geometry::Size {
131 width: taffy::style::Dimension::from_length(40f32),
132 height: taffy::style::Dimension::from_length(20f32),
133 },
134 ..Default::default()
135 })
136 .unwrap();
137 let node13 = taffy
138 .new_leaf(taffy::style::Style {
139 flex_shrink: 0f32,
140 size: taffy::geometry::Size {
141 width: taffy::style::Dimension::from_length(40f32),
142 height: taffy::style::Dimension::from_length(20f32),
143 },
144 ..Default::default()
145 })
146 .unwrap();
147 let node14 = taffy
148 .new_leaf(taffy::style::Style {
149 flex_shrink: 0f32,
150 size: taffy::geometry::Size {
151 width: taffy::style::Dimension::from_length(40f32),
152 height: taffy::style::Dimension::from_length(20f32),
153 },
154 ..Default::default()
155 })
156 .unwrap();
157 let node15 = taffy
158 .new_leaf(taffy::style::Style {
159 flex_shrink: 0f32,
160 size: taffy::geometry::Size {
161 width: taffy::style::Dimension::from_length(40f32),
162 height: taffy::style::Dimension::from_length(20f32),
163 },
164 ..Default::default()
165 })
166 .unwrap();
167 let node16 = taffy
168 .new_leaf(taffy::style::Style {
169 flex_shrink: 0f32,
170 size: taffy::geometry::Size {
171 width: taffy::style::Dimension::from_length(40f32),
172 height: taffy::style::Dimension::from_length(20f32),
173 },
174 ..Default::default()
175 })
176 .unwrap();
177 let node17 = taffy
178 .new_leaf(taffy::style::Style {
179 flex_shrink: 0f32,
180 size: taffy::geometry::Size {
181 width: taffy::style::Dimension::from_length(40f32),
182 height: taffy::style::Dimension::from_length(20f32),
183 },
184 ..Default::default()
185 })
186 .unwrap();
187 let node18 = taffy
188 .new_leaf(taffy::style::Style {
189 flex_shrink: 0f32,
190 size: taffy::geometry::Size {
191 width: taffy::style::Dimension::from_length(40f32),
192 height: taffy::style::Dimension::from_length(20f32),
193 },
194 ..Default::default()
195 })
196 .unwrap();
197 let node19 = taffy
198 .new_leaf(taffy::style::Style {
199 flex_shrink: 0f32,
200 size: taffy::geometry::Size {
201 width: taffy::style::Dimension::from_length(40f32),
202 height: taffy::style::Dimension::from_length(20f32),
203 },
204 ..Default::default()
205 })
206 .unwrap();
207 let node = taffy
208 .new_with_children(
209 taffy::style::Style {
210 display: taffy::style::Display::Flex,
211 flex_direction: taffy::style::FlexDirection::Column,
212 flex_wrap: taffy::style::FlexWrap::Wrap,
213 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) },
214 ..Default::default()
215 },
216 &[
217 node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13,
218 node14, node15, node16, node17, node18, node19,
219 ],
220 )
221 .unwrap();
222 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
223 println!("\nComputed tree:");
224 taffy.print_tree(node);
225 println!();
226 let layout = taffy.layout(node).unwrap();
227 let Layout { size, location, .. } = layout;
228 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
229 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
230 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
231 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
232 let layout = taffy.layout(node0).unwrap();
233 let Layout { size, location, .. } = layout;
234 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
235 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
236 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
237 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
238 let layout = taffy.layout(node1).unwrap();
239 let Layout { size, location, .. } = layout;
240 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
241 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
242 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
243 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y);
244 let layout = taffy.layout(node2).unwrap();
245 let Layout { size, location, .. } = layout;
246 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
247 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
248 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
249 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y);
250 let layout = taffy.layout(node3).unwrap();
251 let Layout { size, location, .. } = layout;
252 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width);
253 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
254 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
255 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y);
256 let layout = taffy.layout(node4).unwrap();
257 let Layout { size, location, .. } = layout;
258 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width);
259 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height);
260 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
261 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y);
262 let layout = taffy.layout(node5).unwrap();
263 let Layout { size, location, .. } = layout;
264 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width);
265 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height);
266 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x);
267 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y);
268 let layout = taffy.layout(node6).unwrap();
269 let Layout { size, location, .. } = layout;
270 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width);
271 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height);
272 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x);
273 assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y);
274 let layout = taffy.layout(node7).unwrap();
275 let Layout { size, location, .. } = layout;
276 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width);
277 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height);
278 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x);
279 assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y);
280 let layout = taffy.layout(node8).unwrap();
281 let Layout { size, location, .. } = layout;
282 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width);
283 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height);
284 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x);
285 assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y);
286 let layout = taffy.layout(node9).unwrap();
287 let Layout { size, location, .. } = layout;
288 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width);
289 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height);
290 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x);
291 assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y);
292 let layout = taffy.layout(node10).unwrap();
293 let Layout { size, location, .. } = layout;
294 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width);
295 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
296 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x);
297 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
298 let layout = taffy.layout(node11).unwrap();
299 let Layout { size, location, .. } = layout;
300 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width);
301 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height);
302 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x);
303 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y);
304 let layout = taffy.layout(node12).unwrap();
305 let Layout { size, location, .. } = layout;
306 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width);
307 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height);
308 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x);
309 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y);
310 let layout = taffy.layout(node13).unwrap();
311 let Layout { size, location, .. } = layout;
312 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width);
313 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height);
314 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x);
315 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y);
316 let layout = taffy.layout(node14).unwrap();
317 let Layout { size, location, .. } = layout;
318 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width);
319 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height);
320 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x);
321 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y);
322 let layout = taffy.layout(node15).unwrap();
323 let Layout { size, location, .. } = layout;
324 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width);
325 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height);
326 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x);
327 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y);
328 let layout = taffy.layout(node16).unwrap();
329 let Layout { size, location, .. } = layout;
330 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width);
331 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height);
332 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x);
333 assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y);
334 let layout = taffy.layout(node17).unwrap();
335 let Layout { size, location, .. } = layout;
336 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width);
337 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height);
338 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x);
339 assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y);
340 let layout = taffy.layout(node18).unwrap();
341 let Layout { size, location, .. } = layout;
342 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width);
343 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height);
344 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x);
345 assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y);
346 let layout = taffy.layout(node19).unwrap();
347 let Layout { size, location, .. } = layout;
348 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width);
349 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height);
350 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x);
351 assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y);
352}
353
354#[test]
355#[allow(non_snake_case)]
356fn multiline_column_max_height__content_box() {
357 #[allow(unused_imports)]
358 use taffy::{prelude::*, Layout};
359 let mut taffy = crate::new_test_tree();
360 let node0 = taffy
361 .new_leaf(taffy::style::Style {
362 box_sizing: taffy::style::BoxSizing::ContentBox,
363 flex_shrink: 0f32,
364 size: taffy::geometry::Size {
365 width: taffy::style::Dimension::from_length(40f32),
366 height: taffy::style::Dimension::from_length(20f32),
367 },
368 ..Default::default()
369 })
370 .unwrap();
371 let node1 = taffy
372 .new_leaf(taffy::style::Style {
373 box_sizing: taffy::style::BoxSizing::ContentBox,
374 flex_shrink: 0f32,
375 size: taffy::geometry::Size {
376 width: taffy::style::Dimension::from_length(40f32),
377 height: taffy::style::Dimension::from_length(20f32),
378 },
379 ..Default::default()
380 })
381 .unwrap();
382 let node2 = taffy
383 .new_leaf(taffy::style::Style {
384 box_sizing: taffy::style::BoxSizing::ContentBox,
385 flex_shrink: 0f32,
386 size: taffy::geometry::Size {
387 width: taffy::style::Dimension::from_length(40f32),
388 height: taffy::style::Dimension::from_length(20f32),
389 },
390 ..Default::default()
391 })
392 .unwrap();
393 let node3 = taffy
394 .new_leaf(taffy::style::Style {
395 box_sizing: taffy::style::BoxSizing::ContentBox,
396 flex_shrink: 0f32,
397 size: taffy::geometry::Size {
398 width: taffy::style::Dimension::from_length(40f32),
399 height: taffy::style::Dimension::from_length(20f32),
400 },
401 ..Default::default()
402 })
403 .unwrap();
404 let node4 = taffy
405 .new_leaf(taffy::style::Style {
406 box_sizing: taffy::style::BoxSizing::ContentBox,
407 flex_shrink: 0f32,
408 size: taffy::geometry::Size {
409 width: taffy::style::Dimension::from_length(40f32),
410 height: taffy::style::Dimension::from_length(20f32),
411 },
412 ..Default::default()
413 })
414 .unwrap();
415 let node5 = taffy
416 .new_leaf(taffy::style::Style {
417 box_sizing: taffy::style::BoxSizing::ContentBox,
418 flex_shrink: 0f32,
419 size: taffy::geometry::Size {
420 width: taffy::style::Dimension::from_length(40f32),
421 height: taffy::style::Dimension::from_length(20f32),
422 },
423 ..Default::default()
424 })
425 .unwrap();
426 let node6 = taffy
427 .new_leaf(taffy::style::Style {
428 box_sizing: taffy::style::BoxSizing::ContentBox,
429 flex_shrink: 0f32,
430 size: taffy::geometry::Size {
431 width: taffy::style::Dimension::from_length(40f32),
432 height: taffy::style::Dimension::from_length(20f32),
433 },
434 ..Default::default()
435 })
436 .unwrap();
437 let node7 = taffy
438 .new_leaf(taffy::style::Style {
439 box_sizing: taffy::style::BoxSizing::ContentBox,
440 flex_shrink: 0f32,
441 size: taffy::geometry::Size {
442 width: taffy::style::Dimension::from_length(40f32),
443 height: taffy::style::Dimension::from_length(20f32),
444 },
445 ..Default::default()
446 })
447 .unwrap();
448 let node8 = taffy
449 .new_leaf(taffy::style::Style {
450 box_sizing: taffy::style::BoxSizing::ContentBox,
451 flex_shrink: 0f32,
452 size: taffy::geometry::Size {
453 width: taffy::style::Dimension::from_length(40f32),
454 height: taffy::style::Dimension::from_length(20f32),
455 },
456 ..Default::default()
457 })
458 .unwrap();
459 let node9 = taffy
460 .new_leaf(taffy::style::Style {
461 box_sizing: taffy::style::BoxSizing::ContentBox,
462 flex_shrink: 0f32,
463 size: taffy::geometry::Size {
464 width: taffy::style::Dimension::from_length(40f32),
465 height: taffy::style::Dimension::from_length(20f32),
466 },
467 ..Default::default()
468 })
469 .unwrap();
470 let node10 = taffy
471 .new_leaf(taffy::style::Style {
472 box_sizing: taffy::style::BoxSizing::ContentBox,
473 flex_shrink: 0f32,
474 size: taffy::geometry::Size {
475 width: taffy::style::Dimension::from_length(40f32),
476 height: taffy::style::Dimension::from_length(20f32),
477 },
478 ..Default::default()
479 })
480 .unwrap();
481 let node11 = taffy
482 .new_leaf(taffy::style::Style {
483 box_sizing: taffy::style::BoxSizing::ContentBox,
484 flex_shrink: 0f32,
485 size: taffy::geometry::Size {
486 width: taffy::style::Dimension::from_length(40f32),
487 height: taffy::style::Dimension::from_length(20f32),
488 },
489 ..Default::default()
490 })
491 .unwrap();
492 let node12 = taffy
493 .new_leaf(taffy::style::Style {
494 box_sizing: taffy::style::BoxSizing::ContentBox,
495 flex_shrink: 0f32,
496 size: taffy::geometry::Size {
497 width: taffy::style::Dimension::from_length(40f32),
498 height: taffy::style::Dimension::from_length(20f32),
499 },
500 ..Default::default()
501 })
502 .unwrap();
503 let node13 = taffy
504 .new_leaf(taffy::style::Style {
505 box_sizing: taffy::style::BoxSizing::ContentBox,
506 flex_shrink: 0f32,
507 size: taffy::geometry::Size {
508 width: taffy::style::Dimension::from_length(40f32),
509 height: taffy::style::Dimension::from_length(20f32),
510 },
511 ..Default::default()
512 })
513 .unwrap();
514 let node14 = taffy
515 .new_leaf(taffy::style::Style {
516 box_sizing: taffy::style::BoxSizing::ContentBox,
517 flex_shrink: 0f32,
518 size: taffy::geometry::Size {
519 width: taffy::style::Dimension::from_length(40f32),
520 height: taffy::style::Dimension::from_length(20f32),
521 },
522 ..Default::default()
523 })
524 .unwrap();
525 let node15 = taffy
526 .new_leaf(taffy::style::Style {
527 box_sizing: taffy::style::BoxSizing::ContentBox,
528 flex_shrink: 0f32,
529 size: taffy::geometry::Size {
530 width: taffy::style::Dimension::from_length(40f32),
531 height: taffy::style::Dimension::from_length(20f32),
532 },
533 ..Default::default()
534 })
535 .unwrap();
536 let node16 = taffy
537 .new_leaf(taffy::style::Style {
538 box_sizing: taffy::style::BoxSizing::ContentBox,
539 flex_shrink: 0f32,
540 size: taffy::geometry::Size {
541 width: taffy::style::Dimension::from_length(40f32),
542 height: taffy::style::Dimension::from_length(20f32),
543 },
544 ..Default::default()
545 })
546 .unwrap();
547 let node17 = taffy
548 .new_leaf(taffy::style::Style {
549 box_sizing: taffy::style::BoxSizing::ContentBox,
550 flex_shrink: 0f32,
551 size: taffy::geometry::Size {
552 width: taffy::style::Dimension::from_length(40f32),
553 height: taffy::style::Dimension::from_length(20f32),
554 },
555 ..Default::default()
556 })
557 .unwrap();
558 let node18 = taffy
559 .new_leaf(taffy::style::Style {
560 box_sizing: taffy::style::BoxSizing::ContentBox,
561 flex_shrink: 0f32,
562 size: taffy::geometry::Size {
563 width: taffy::style::Dimension::from_length(40f32),
564 height: taffy::style::Dimension::from_length(20f32),
565 },
566 ..Default::default()
567 })
568 .unwrap();
569 let node19 = taffy
570 .new_leaf(taffy::style::Style {
571 box_sizing: taffy::style::BoxSizing::ContentBox,
572 flex_shrink: 0f32,
573 size: taffy::geometry::Size {
574 width: taffy::style::Dimension::from_length(40f32),
575 height: taffy::style::Dimension::from_length(20f32),
576 },
577 ..Default::default()
578 })
579 .unwrap();
580 let node = taffy
581 .new_with_children(
582 taffy::style::Style {
583 display: taffy::style::Display::Flex,
584 box_sizing: taffy::style::BoxSizing::ContentBox,
585 flex_direction: taffy::style::FlexDirection::Column,
586 flex_wrap: taffy::style::FlexWrap::Wrap,
587 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(200f32) },
588 ..Default::default()
589 },
590 &[
591 node0, node1, node2, node3, node4, node5, node6, node7, node8, node9, node10, node11, node12, node13,
592 node14, node15, node16, node17, node18, node19,
593 ],
594 )
595 .unwrap();
596 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
597 println!("\nComputed tree:");
598 taffy.print_tree(node);
599 println!();
600 let layout = taffy.layout(node).unwrap();
601 let Layout { size, location, .. } = layout;
602 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
603 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
604 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
605 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
606 let layout = taffy.layout(node0).unwrap();
607 let Layout { size, location, .. } = layout;
608 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
609 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
610 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
611 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
612 let layout = taffy.layout(node1).unwrap();
613 let Layout { size, location, .. } = layout;
614 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
615 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
616 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
617 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y);
618 let layout = taffy.layout(node2).unwrap();
619 let Layout { size, location, .. } = layout;
620 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
621 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
622 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
623 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y);
624 let layout = taffy.layout(node3).unwrap();
625 let Layout { size, location, .. } = layout;
626 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width);
627 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
628 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
629 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node3, 60f32, location.y);
630 let layout = taffy.layout(node4).unwrap();
631 let Layout { size, location, .. } = layout;
632 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width);
633 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height);
634 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
635 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y);
636 let layout = taffy.layout(node5).unwrap();
637 let Layout { size, location, .. } = layout;
638 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width);
639 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height);
640 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x);
641 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node5, 100f32, location.y);
642 let layout = taffy.layout(node6).unwrap();
643 let Layout { size, location, .. } = layout;
644 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width);
645 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node6, 20f32, size.height);
646 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node6, 0f32, location.x);
647 assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node6, 120f32, location.y);
648 let layout = taffy.layout(node7).unwrap();
649 let Layout { size, location, .. } = layout;
650 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width);
651 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node7, 20f32, size.height);
652 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node7, 0f32, location.x);
653 assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node7, 140f32, location.y);
654 let layout = taffy.layout(node8).unwrap();
655 let Layout { size, location, .. } = layout;
656 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width);
657 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node8, 20f32, size.height);
658 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node8, 0f32, location.x);
659 assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node8, 160f32, location.y);
660 let layout = taffy.layout(node9).unwrap();
661 let Layout { size, location, .. } = layout;
662 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node9, 40f32, size.width);
663 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node9, 20f32, size.height);
664 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node9, 0f32, location.x);
665 assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node9, 180f32, location.y);
666 let layout = taffy.layout(node10).unwrap();
667 let Layout { size, location, .. } = layout;
668 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node10, 40f32, size.width);
669 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
670 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node10, 40f32, location.x);
671 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
672 let layout = taffy.layout(node11).unwrap();
673 let Layout { size, location, .. } = layout;
674 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node11, 40f32, size.width);
675 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node11, 20f32, size.height);
676 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x);
677 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node11, 20f32, location.y);
678 let layout = taffy.layout(node12).unwrap();
679 let Layout { size, location, .. } = layout;
680 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node12, 40f32, size.width);
681 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height);
682 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node12, 40f32, location.x);
683 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node12, 40f32, location.y);
684 let layout = taffy.layout(node13).unwrap();
685 let Layout { size, location, .. } = layout;
686 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node13, 40f32, size.width);
687 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node13, 20f32, size.height);
688 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node13, 40f32, location.x);
689 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node13, 60f32, location.y);
690 let layout = taffy.layout(node14).unwrap();
691 let Layout { size, location, .. } = layout;
692 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node14, 40f32, size.width);
693 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node14, 20f32, size.height);
694 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node14, 40f32, location.x);
695 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node14, 80f32, location.y);
696 let layout = taffy.layout(node15).unwrap();
697 let Layout { size, location, .. } = layout;
698 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node15, 40f32, size.width);
699 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node15, 20f32, size.height);
700 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node15, 40f32, location.x);
701 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node15, 100f32, location.y);
702 let layout = taffy.layout(node16).unwrap();
703 let Layout { size, location, .. } = layout;
704 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node16, 40f32, size.width);
705 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node16, 20f32, size.height);
706 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node16, 40f32, location.x);
707 assert_eq!(location.y, 120f32, "y of node {:?}. Expected {}. Actual {}", node16, 120f32, location.y);
708 let layout = taffy.layout(node17).unwrap();
709 let Layout { size, location, .. } = layout;
710 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node17, 40f32, size.width);
711 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node17, 20f32, size.height);
712 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node17, 40f32, location.x);
713 assert_eq!(location.y, 140f32, "y of node {:?}. Expected {}. Actual {}", node17, 140f32, location.y);
714 let layout = taffy.layout(node18).unwrap();
715 let Layout { size, location, .. } = layout;
716 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node18, 40f32, size.width);
717 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node18, 20f32, size.height);
718 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node18, 40f32, location.x);
719 assert_eq!(location.y, 160f32, "y of node {:?}. Expected {}. Actual {}", node18, 160f32, location.y);
720 let layout = taffy.layout(node19).unwrap();
721 let Layout { size, location, .. } = layout;
722 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node19, 40f32, size.width);
723 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node19, 20f32, size.height);
724 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node19, 40f32, location.x);
725 assert_eq!(location.y, 180f32, "y of node {:?}. Expected {}. Actual {}", node19, 180f32, location.y);
726}