⎇ b746ac4f346dde8a2b6f85d3a428c02a2342f099
tests/generated/flex/align_baseline_double_nested_child.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn align_baseline_double_nested_child__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(50f32),
11 height: taffy::style::Dimension::Length(20f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::Length(50f32),
21 height: taffy::style::Dimension::Length(50f32),
22 },
23 ..Default::default()
24 },
25 &[node00],
26 )
27 .unwrap();
28 let node10 = taffy
29 .new_leaf(taffy::style::Style {
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::Length(50f32),
32 height: taffy::style::Dimension::Length(15f32),
33 },
34 ..Default::default()
35 })
36 .unwrap();
37 let node1 = taffy
38 .new_with_children(
39 taffy::style::Style {
40 size: taffy::geometry::Size {
41 width: taffy::style::Dimension::Length(50f32),
42 height: taffy::style::Dimension::Length(20f32),
43 },
44 ..Default::default()
45 },
46 &[node10],
47 )
48 .unwrap();
49 let node = taffy
50 .new_with_children(
51 taffy::style::Style {
52 align_items: Some(taffy::style::AlignItems::Baseline),
53 size: taffy::geometry::Size {
54 width: taffy::style::Dimension::Length(100f32),
55 height: taffy::style::Dimension::Length(100f32),
56 },
57 ..Default::default()
58 },
59 &[node0, node1],
60 )
61 .unwrap();
62 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
63 println!("\nComputed tree:");
64 taffy.print_tree(node);
65 println!();
66 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
67 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
68 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
69 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
70 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
72 #[cfg(feature = "content_size")]
73 assert_eq!(
74 layout.scroll_width(),
75 0f32,
76 "scroll_width of node {:?}. Expected {}. Actual {}",
77 node,
78 0f32,
79 layout.scroll_width()
80 );
81 #[cfg(feature = "content_size")]
82 assert_eq!(
83 layout.scroll_height(),
84 0f32,
85 "scroll_height of node {:?}. Expected {}. Actual {}",
86 node,
87 0f32,
88 layout.scroll_height()
89 );
90 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
91 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
92 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
93 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
94 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
95 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
96 #[cfg(feature = "content_size")]
97 assert_eq!(
98 layout.scroll_width(),
99 0f32,
100 "scroll_width of node {:?}. Expected {}. Actual {}",
101 node0,
102 0f32,
103 layout.scroll_width()
104 );
105 #[cfg(feature = "content_size")]
106 assert_eq!(
107 layout.scroll_height(),
108 0f32,
109 "scroll_height of node {:?}. Expected {}. Actual {}",
110 node0,
111 0f32,
112 layout.scroll_height()
113 );
114 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
115 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
116 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
117 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
120 #[cfg(feature = "content_size")]
121 assert_eq!(
122 layout.scroll_width(),
123 0f32,
124 "scroll_width of node {:?}. Expected {}. Actual {}",
125 node00,
126 0f32,
127 layout.scroll_width()
128 );
129 #[cfg(feature = "content_size")]
130 assert_eq!(
131 layout.scroll_height(),
132 0f32,
133 "scroll_height of node {:?}. Expected {}. Actual {}",
134 node00,
135 0f32,
136 layout.scroll_height()
137 );
138 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
139 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
140 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
141 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
142 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
143 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y);
144 #[cfg(feature = "content_size")]
145 assert_eq!(
146 layout.scroll_width(),
147 0f32,
148 "scroll_width of node {:?}. Expected {}. Actual {}",
149 node1,
150 0f32,
151 layout.scroll_width()
152 );
153 #[cfg(feature = "content_size")]
154 assert_eq!(
155 layout.scroll_height(),
156 0f32,
157 "scroll_height of node {:?}. Expected {}. Actual {}",
158 node1,
159 0f32,
160 layout.scroll_height()
161 );
162 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
163 let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
164 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
165 assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height);
166 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
167 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
168 #[cfg(feature = "content_size")]
169 assert_eq!(
170 layout.scroll_width(),
171 0f32,
172 "scroll_width of node {:?}. Expected {}. Actual {}",
173 node10,
174 0f32,
175 layout.scroll_width()
176 );
177 #[cfg(feature = "content_size")]
178 assert_eq!(
179 layout.scroll_height(),
180 0f32,
181 "scroll_height of node {:?}. Expected {}. Actual {}",
182 node10,
183 0f32,
184 layout.scroll_height()
185 );
186}
187
188#[test]
189#[allow(non_snake_case)]
190fn align_baseline_double_nested_child__content_box() {
191 #[allow(unused_imports)]
192 use taffy::{prelude::*, tree::Layout, TaffyTree};
193 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
194 let node00 = taffy
195 .new_leaf(taffy::style::Style {
196 box_sizing: taffy::style::BoxSizing::ContentBox,
197 size: taffy::geometry::Size {
198 width: taffy::style::Dimension::Length(50f32),
199 height: taffy::style::Dimension::Length(20f32),
200 },
201 ..Default::default()
202 })
203 .unwrap();
204 let node0 = taffy
205 .new_with_children(
206 taffy::style::Style {
207 box_sizing: taffy::style::BoxSizing::ContentBox,
208 size: taffy::geometry::Size {
209 width: taffy::style::Dimension::Length(50f32),
210 height: taffy::style::Dimension::Length(50f32),
211 },
212 ..Default::default()
213 },
214 &[node00],
215 )
216 .unwrap();
217 let node10 = taffy
218 .new_leaf(taffy::style::Style {
219 box_sizing: taffy::style::BoxSizing::ContentBox,
220 size: taffy::geometry::Size {
221 width: taffy::style::Dimension::Length(50f32),
222 height: taffy::style::Dimension::Length(15f32),
223 },
224 ..Default::default()
225 })
226 .unwrap();
227 let node1 = taffy
228 .new_with_children(
229 taffy::style::Style {
230 box_sizing: taffy::style::BoxSizing::ContentBox,
231 size: taffy::geometry::Size {
232 width: taffy::style::Dimension::Length(50f32),
233 height: taffy::style::Dimension::Length(20f32),
234 },
235 ..Default::default()
236 },
237 &[node10],
238 )
239 .unwrap();
240 let node = taffy
241 .new_with_children(
242 taffy::style::Style {
243 box_sizing: taffy::style::BoxSizing::ContentBox,
244 align_items: Some(taffy::style::AlignItems::Baseline),
245 size: taffy::geometry::Size {
246 width: taffy::style::Dimension::Length(100f32),
247 height: taffy::style::Dimension::Length(100f32),
248 },
249 ..Default::default()
250 },
251 &[node0, node1],
252 )
253 .unwrap();
254 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
255 println!("\nComputed tree:");
256 taffy.print_tree(node);
257 println!();
258 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
259 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
260 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
261 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
262 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
263 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
264 #[cfg(feature = "content_size")]
265 assert_eq!(
266 layout.scroll_width(),
267 0f32,
268 "scroll_width of node {:?}. Expected {}. Actual {}",
269 node,
270 0f32,
271 layout.scroll_width()
272 );
273 #[cfg(feature = "content_size")]
274 assert_eq!(
275 layout.scroll_height(),
276 0f32,
277 "scroll_height of node {:?}. Expected {}. Actual {}",
278 node,
279 0f32,
280 layout.scroll_height()
281 );
282 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
283 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
284 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
285 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
286 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
287 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
288 #[cfg(feature = "content_size")]
289 assert_eq!(
290 layout.scroll_width(),
291 0f32,
292 "scroll_width of node {:?}. Expected {}. Actual {}",
293 node0,
294 0f32,
295 layout.scroll_width()
296 );
297 #[cfg(feature = "content_size")]
298 assert_eq!(
299 layout.scroll_height(),
300 0f32,
301 "scroll_height of node {:?}. Expected {}. Actual {}",
302 node0,
303 0f32,
304 layout.scroll_height()
305 );
306 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
307 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
308 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
309 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
310 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
311 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 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 node00,
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 node00,
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(node1).unwrap();
332 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
333 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
334 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
335 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node1, 5f32, location.y);
336 #[cfg(feature = "content_size")]
337 assert_eq!(
338 layout.scroll_width(),
339 0f32,
340 "scroll_width of node {:?}. Expected {}. Actual {}",
341 node1,
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 node1,
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(node10).unwrap();
356 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
357 assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node10, 15f32, size.height);
358 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
359 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
360 #[cfg(feature = "content_size")]
361 assert_eq!(
362 layout.scroll_width(),
363 0f32,
364 "scroll_width of node {:?}. Expected {}. Actual {}",
365 node10,
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 node10,
375 0f32,
376 layout.scroll_height()
377 );
378}