⎇ b746ac4f346dde8a2b6f85d3a428c02a2342f099
tests/generated/flex/gap_row_gap_align_items_end.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn gap_row_gap_align_items_end__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 let node1 = taffy
14 .new_leaf(taffy::style::Style {
15 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
16 ..Default::default()
17 })
18 .unwrap();
19 let node2 = taffy
20 .new_leaf(taffy::style::Style {
21 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
22 ..Default::default()
23 })
24 .unwrap();
25 let node3 = taffy
26 .new_leaf(taffy::style::Style {
27 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
28 ..Default::default()
29 })
30 .unwrap();
31 let node4 = taffy
32 .new_leaf(taffy::style::Style {
33 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
34 ..Default::default()
35 })
36 .unwrap();
37 let node5 = taffy
38 .new_leaf(taffy::style::Style {
39 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
40 ..Default::default()
41 })
42 .unwrap();
43 let node = taffy
44 .new_with_children(
45 taffy::style::Style {
46 flex_wrap: taffy::style::FlexWrap::Wrap,
47 align_items: Some(taffy::style::AlignItems::FlexEnd),
48 gap: taffy::geometry::Size {
49 width: taffy::style::LengthPercentage::Length(10f32),
50 height: taffy::style::LengthPercentage::Length(20f32),
51 },
52 size: taffy::geometry::Size {
53 width: taffy::style::Dimension::Length(100f32),
54 height: taffy::style::Dimension::Length(200f32),
55 },
56 ..Default::default()
57 },
58 &[node0, node1, node2, node3, node4, node5],
59 )
60 .unwrap();
61 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
62 println!("\nComputed tree:");
63 taffy.print_tree(node);
64 println!();
65 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
66 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
67 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
68 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
69 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
70 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
71 #[cfg(feature = "content_size")]
72 assert_eq!(
73 layout.scroll_width(),
74 0f32,
75 "scroll_width of node {:?}. Expected {}. Actual {}",
76 node,
77 0f32,
78 layout.scroll_width()
79 );
80 #[cfg(feature = "content_size")]
81 assert_eq!(
82 layout.scroll_height(),
83 0f32,
84 "scroll_height of node {:?}. Expected {}. Actual {}",
85 node,
86 0f32,
87 layout.scroll_height()
88 );
89 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
90 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
91 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
92 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
93 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
94 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y);
95 #[cfg(feature = "content_size")]
96 assert_eq!(
97 layout.scroll_width(),
98 0f32,
99 "scroll_width of node {:?}. Expected {}. Actual {}",
100 node0,
101 0f32,
102 layout.scroll_width()
103 );
104 #[cfg(feature = "content_size")]
105 assert_eq!(
106 layout.scroll_height(),
107 0f32,
108 "scroll_height of node {:?}. Expected {}. Actual {}",
109 node0,
110 0f32,
111 layout.scroll_height()
112 );
113 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
114 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
115 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
116 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
117 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
118 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y);
119 #[cfg(feature = "content_size")]
120 assert_eq!(
121 layout.scroll_width(),
122 0f32,
123 "scroll_width of node {:?}. Expected {}. Actual {}",
124 node1,
125 0f32,
126 layout.scroll_width()
127 );
128 #[cfg(feature = "content_size")]
129 assert_eq!(
130 layout.scroll_height(),
131 0f32,
132 "scroll_height of node {:?}. Expected {}. Actual {}",
133 node1,
134 0f32,
135 layout.scroll_height()
136 );
137 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
138 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
139 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
140 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height);
141 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
142 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y);
143 #[cfg(feature = "content_size")]
144 assert_eq!(
145 layout.scroll_width(),
146 0f32,
147 "scroll_width of node {:?}. Expected {}. Actual {}",
148 node2,
149 0f32,
150 layout.scroll_width()
151 );
152 #[cfg(feature = "content_size")]
153 assert_eq!(
154 layout.scroll_height(),
155 0f32,
156 "scroll_height of node {:?}. Expected {}. Actual {}",
157 node2,
158 0f32,
159 layout.scroll_height()
160 );
161 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
162 let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
163 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
164 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height);
165 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
166 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y);
167 #[cfg(feature = "content_size")]
168 assert_eq!(
169 layout.scroll_width(),
170 0f32,
171 "scroll_width of node {:?}. Expected {}. Actual {}",
172 node3,
173 0f32,
174 layout.scroll_width()
175 );
176 #[cfg(feature = "content_size")]
177 assert_eq!(
178 layout.scroll_height(),
179 0f32,
180 "scroll_height of node {:?}. Expected {}. Actual {}",
181 node3,
182 0f32,
183 layout.scroll_height()
184 );
185 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
186 let layout @ Layout { size, location, .. } = taffy.layout(node4).unwrap();
187 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
188 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height);
189 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
190 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y);
191 #[cfg(feature = "content_size")]
192 assert_eq!(
193 layout.scroll_width(),
194 0f32,
195 "scroll_width of node {:?}. Expected {}. Actual {}",
196 node4,
197 0f32,
198 layout.scroll_width()
199 );
200 #[cfg(feature = "content_size")]
201 assert_eq!(
202 layout.scroll_height(),
203 0f32,
204 "scroll_height of node {:?}. Expected {}. Actual {}",
205 node4,
206 0f32,
207 layout.scroll_height()
208 );
209 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
210 let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap();
211 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
212 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height);
213 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
214 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5, 200f32, location.y);
215 #[cfg(feature = "content_size")]
216 assert_eq!(
217 layout.scroll_width(),
218 0f32,
219 "scroll_width of node {:?}. Expected {}. Actual {}",
220 node5,
221 0f32,
222 layout.scroll_width()
223 );
224 #[cfg(feature = "content_size")]
225 assert_eq!(
226 layout.scroll_height(),
227 0f32,
228 "scroll_height of node {:?}. Expected {}. Actual {}",
229 node5,
230 0f32,
231 layout.scroll_height()
232 );
233}
234
235#[test]
236#[allow(non_snake_case)]
237fn gap_row_gap_align_items_end__content_box() {
238 #[allow(unused_imports)]
239 use taffy::{prelude::*, tree::Layout, TaffyTree};
240 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
241 let node0 = taffy
242 .new_leaf(taffy::style::Style {
243 box_sizing: taffy::style::BoxSizing::ContentBox,
244 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
245 ..Default::default()
246 })
247 .unwrap();
248 let node1 = taffy
249 .new_leaf(taffy::style::Style {
250 box_sizing: taffy::style::BoxSizing::ContentBox,
251 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
252 ..Default::default()
253 })
254 .unwrap();
255 let node2 = taffy
256 .new_leaf(taffy::style::Style {
257 box_sizing: taffy::style::BoxSizing::ContentBox,
258 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
259 ..Default::default()
260 })
261 .unwrap();
262 let node3 = taffy
263 .new_leaf(taffy::style::Style {
264 box_sizing: taffy::style::BoxSizing::ContentBox,
265 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
266 ..Default::default()
267 })
268 .unwrap();
269 let node4 = taffy
270 .new_leaf(taffy::style::Style {
271 box_sizing: taffy::style::BoxSizing::ContentBox,
272 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
273 ..Default::default()
274 })
275 .unwrap();
276 let node5 = taffy
277 .new_leaf(taffy::style::Style {
278 box_sizing: taffy::style::BoxSizing::ContentBox,
279 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
280 ..Default::default()
281 })
282 .unwrap();
283 let node = taffy
284 .new_with_children(
285 taffy::style::Style {
286 box_sizing: taffy::style::BoxSizing::ContentBox,
287 flex_wrap: taffy::style::FlexWrap::Wrap,
288 align_items: Some(taffy::style::AlignItems::FlexEnd),
289 gap: taffy::geometry::Size {
290 width: taffy::style::LengthPercentage::Length(10f32),
291 height: taffy::style::LengthPercentage::Length(20f32),
292 },
293 size: taffy::geometry::Size {
294 width: taffy::style::Dimension::Length(100f32),
295 height: taffy::style::Dimension::Length(200f32),
296 },
297 ..Default::default()
298 },
299 &[node0, node1, node2, node3, node4, node5],
300 )
301 .unwrap();
302 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
303 println!("\nComputed tree:");
304 taffy.print_tree(node);
305 println!();
306 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
307 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
308 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
309 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
310 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
311 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
312 #[cfg(feature = "content_size")]
313 assert_eq!(
314 layout.scroll_width(),
315 0f32,
316 "scroll_width of node {:?}. Expected {}. Actual {}",
317 node,
318 0f32,
319 layout.scroll_width()
320 );
321 #[cfg(feature = "content_size")]
322 assert_eq!(
323 layout.scroll_height(),
324 0f32,
325 "scroll_height of node {:?}. Expected {}. Actual {}",
326 node,
327 0f32,
328 layout.scroll_height()
329 );
330 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
331 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
332 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
333 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
334 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
335 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y);
336 #[cfg(feature = "content_size")]
337 assert_eq!(
338 layout.scroll_width(),
339 0f32,
340 "scroll_width of node {:?}. Expected {}. Actual {}",
341 node0,
342 0f32,
343 layout.scroll_width()
344 );
345 #[cfg(feature = "content_size")]
346 assert_eq!(
347 layout.scroll_height(),
348 0f32,
349 "scroll_height of node {:?}. Expected {}. Actual {}",
350 node0,
351 0f32,
352 layout.scroll_height()
353 );
354 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
355 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
356 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
357 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
358 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
359 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y);
360 #[cfg(feature = "content_size")]
361 assert_eq!(
362 layout.scroll_width(),
363 0f32,
364 "scroll_width of node {:?}. Expected {}. Actual {}",
365 node1,
366 0f32,
367 layout.scroll_width()
368 );
369 #[cfg(feature = "content_size")]
370 assert_eq!(
371 layout.scroll_height(),
372 0f32,
373 "scroll_height of node {:?}. Expected {}. Actual {}",
374 node1,
375 0f32,
376 layout.scroll_height()
377 );
378 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
379 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
380 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
381 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height);
382 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
383 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y);
384 #[cfg(feature = "content_size")]
385 assert_eq!(
386 layout.scroll_width(),
387 0f32,
388 "scroll_width of node {:?}. Expected {}. Actual {}",
389 node2,
390 0f32,
391 layout.scroll_width()
392 );
393 #[cfg(feature = "content_size")]
394 assert_eq!(
395 layout.scroll_height(),
396 0f32,
397 "scroll_height of node {:?}. Expected {}. Actual {}",
398 node2,
399 0f32,
400 layout.scroll_height()
401 );
402 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
403 let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
404 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
405 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height);
406 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
407 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y);
408 #[cfg(feature = "content_size")]
409 assert_eq!(
410 layout.scroll_width(),
411 0f32,
412 "scroll_width of node {:?}. Expected {}. Actual {}",
413 node3,
414 0f32,
415 layout.scroll_width()
416 );
417 #[cfg(feature = "content_size")]
418 assert_eq!(
419 layout.scroll_height(),
420 0f32,
421 "scroll_height of node {:?}. Expected {}. Actual {}",
422 node3,
423 0f32,
424 layout.scroll_height()
425 );
426 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
427 let layout @ Layout { size, location, .. } = taffy.layout(node4).unwrap();
428 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
429 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height);
430 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
431 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y);
432 #[cfg(feature = "content_size")]
433 assert_eq!(
434 layout.scroll_width(),
435 0f32,
436 "scroll_width of node {:?}. Expected {}. Actual {}",
437 node4,
438 0f32,
439 layout.scroll_width()
440 );
441 #[cfg(feature = "content_size")]
442 assert_eq!(
443 layout.scroll_height(),
444 0f32,
445 "scroll_height of node {:?}. Expected {}. Actual {}",
446 node4,
447 0f32,
448 layout.scroll_height()
449 );
450 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
451 let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap();
452 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
453 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height);
454 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
455 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5, 200f32, location.y);
456 #[cfg(feature = "content_size")]
457 assert_eq!(
458 layout.scroll_width(),
459 0f32,
460 "scroll_width of node {:?}. Expected {}. Actual {}",
461 node5,
462 0f32,
463 layout.scroll_width()
464 );
465 #[cfg(feature = "content_size")]
466 assert_eq!(
467 layout.scroll_height(),
468 0f32,
469 "scroll_height of node {:?}. Expected {}. Actual {}",
470 node5,
471 0f32,
472 layout.scroll_height()
473 );
474}