⎇ 25571b5d07206880207e451af69dd3b49b113628
tests/generated/flex/align_content_space_between_wrapped_negative_space.rs
History
Who touched what
raw
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn align_content_space_between_wrapped_negative_space__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 flex_shrink: 0f32,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::Percent(0.8f32),
12 height: taffy::style::Dimension::Length(20f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node01 = taffy
18 .new_leaf(taffy::style::Style {
19 flex_shrink: 0f32,
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::Percent(0.8f32),
22 height: taffy::style::Dimension::Length(20f32),
23 },
24 ..Default::default()
25 })
26 .unwrap();
27 let node02 = taffy
28 .new_leaf(taffy::style::Style {
29 flex_shrink: 0f32,
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::Percent(0.8f32),
32 height: taffy::style::Dimension::Length(20f32),
33 },
34 ..Default::default()
35 })
36 .unwrap();
37 let node0 = taffy
38 .new_with_children(
39 taffy::style::Style {
40 display: taffy::style::Display::Flex,
41 flex_wrap: taffy::style::FlexWrap::Wrap,
42 align_content: Some(taffy::style::AlignContent::SpaceBetween),
43 justify_content: Some(taffy::style::JustifyContent::Center),
44 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) },
45 ..Default::default()
46 },
47 &[node00, node01, node02],
48 )
49 .unwrap();
50 let node = taffy
51 .new_with_children(
52 taffy::style::Style {
53 display: taffy::style::Display::Flex,
54 flex_direction: taffy::style::FlexDirection::Column,
55 size: taffy::geometry::Size {
56 width: taffy::style::Dimension::Length(320f32),
57 height: taffy::style::Dimension::Length(320f32),
58 },
59 border: taffy::geometry::Rect {
60 left: taffy::style::LengthPercentage::Length(60f32),
61 right: taffy::style::LengthPercentage::Length(60f32),
62 top: taffy::style::LengthPercentage::Length(60f32),
63 bottom: taffy::style::LengthPercentage::Length(60f32),
64 },
65 ..Default::default()
66 },
67 &[node0],
68 )
69 .unwrap();
70 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
71 println!("\nComputed tree:");
72 taffy.print_tree(node);
73 println!();
74 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
75 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
76 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
77 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
78 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
79 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
80 #[cfg(feature = "content_size")]
81 assert_eq!(
82 layout.scroll_width(),
83 0f32,
84 "scroll_width of node {:?}. Expected {}. Actual {}",
85 node,
86 0f32,
87 layout.scroll_width()
88 );
89 #[cfg(feature = "content_size")]
90 assert_eq!(
91 layout.scroll_height(),
92 0f32,
93 "scroll_height of node {:?}. Expected {}. Actual {}",
94 node,
95 0f32,
96 layout.scroll_height()
97 );
98 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
99 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
100 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
101 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
102 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
103 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
104 #[cfg(feature = "content_size")]
105 assert_eq!(
106 layout.scroll_width(),
107 0f32,
108 "scroll_width of node {:?}. Expected {}. Actual {}",
109 node0,
110 0f32,
111 layout.scroll_width()
112 );
113 #[cfg(feature = "content_size")]
114 assert_eq!(
115 layout.scroll_height(),
116 50f32,
117 "scroll_height of node {:?}. Expected {}. Actual {}",
118 node0,
119 50f32,
120 layout.scroll_height()
121 );
122 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
123 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
124 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
125 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
126 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
127 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
128 #[cfg(feature = "content_size")]
129 assert_eq!(
130 layout.scroll_width(),
131 0f32,
132 "scroll_width of node {:?}. Expected {}. Actual {}",
133 node00,
134 0f32,
135 layout.scroll_width()
136 );
137 #[cfg(feature = "content_size")]
138 assert_eq!(
139 layout.scroll_height(),
140 0f32,
141 "scroll_height of node {:?}. Expected {}. Actual {}",
142 node00,
143 0f32,
144 layout.scroll_height()
145 );
146 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
147 let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
148 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01, 160f32, size.width);
149 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
150 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01, 20f32, location.x);
151 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y);
152 #[cfg(feature = "content_size")]
153 assert_eq!(
154 layout.scroll_width(),
155 0f32,
156 "scroll_width of node {:?}. Expected {}. Actual {}",
157 node01,
158 0f32,
159 layout.scroll_width()
160 );
161 #[cfg(feature = "content_size")]
162 assert_eq!(
163 layout.scroll_height(),
164 0f32,
165 "scroll_height of node {:?}. Expected {}. Actual {}",
166 node01,
167 0f32,
168 layout.scroll_height()
169 );
170 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
171 let layout @ Layout { size, location, .. } = taffy.layout(node02).unwrap();
172 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02, 160f32, size.width);
173 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height);
174 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02, 20f32, location.x);
175 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y);
176 #[cfg(feature = "content_size")]
177 assert_eq!(
178 layout.scroll_width(),
179 0f32,
180 "scroll_width of node {:?}. Expected {}. Actual {}",
181 node02,
182 0f32,
183 layout.scroll_width()
184 );
185 #[cfg(feature = "content_size")]
186 assert_eq!(
187 layout.scroll_height(),
188 0f32,
189 "scroll_height of node {:?}. Expected {}. Actual {}",
190 node02,
191 0f32,
192 layout.scroll_height()
193 );
194}
195
196#[test]
197#[allow(non_snake_case)]
198fn align_content_space_between_wrapped_negative_space__content_box() {
199 #[allow(unused_imports)]
200 use taffy::{prelude::*, tree::Layout, TaffyTree};
201 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
202 let node00 = taffy
203 .new_leaf(taffy::style::Style {
204 box_sizing: taffy::style::BoxSizing::ContentBox,
205 flex_shrink: 0f32,
206 size: taffy::geometry::Size {
207 width: taffy::style::Dimension::Percent(0.8f32),
208 height: taffy::style::Dimension::Length(20f32),
209 },
210 ..Default::default()
211 })
212 .unwrap();
213 let node01 = taffy
214 .new_leaf(taffy::style::Style {
215 box_sizing: taffy::style::BoxSizing::ContentBox,
216 flex_shrink: 0f32,
217 size: taffy::geometry::Size {
218 width: taffy::style::Dimension::Percent(0.8f32),
219 height: taffy::style::Dimension::Length(20f32),
220 },
221 ..Default::default()
222 })
223 .unwrap();
224 let node02 = taffy
225 .new_leaf(taffy::style::Style {
226 box_sizing: taffy::style::BoxSizing::ContentBox,
227 flex_shrink: 0f32,
228 size: taffy::geometry::Size {
229 width: taffy::style::Dimension::Percent(0.8f32),
230 height: taffy::style::Dimension::Length(20f32),
231 },
232 ..Default::default()
233 })
234 .unwrap();
235 let node0 = taffy
236 .new_with_children(
237 taffy::style::Style {
238 display: taffy::style::Display::Flex,
239 box_sizing: taffy::style::BoxSizing::ContentBox,
240 flex_wrap: taffy::style::FlexWrap::Wrap,
241 align_content: Some(taffy::style::AlignContent::SpaceBetween),
242 justify_content: Some(taffy::style::JustifyContent::Center),
243 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) },
244 ..Default::default()
245 },
246 &[node00, node01, node02],
247 )
248 .unwrap();
249 let node = taffy
250 .new_with_children(
251 taffy::style::Style {
252 display: taffy::style::Display::Flex,
253 box_sizing: taffy::style::BoxSizing::ContentBox,
254 flex_direction: taffy::style::FlexDirection::Column,
255 size: taffy::geometry::Size {
256 width: taffy::style::Dimension::Length(320f32),
257 height: taffy::style::Dimension::Length(320f32),
258 },
259 border: taffy::geometry::Rect {
260 left: taffy::style::LengthPercentage::Length(60f32),
261 right: taffy::style::LengthPercentage::Length(60f32),
262 top: taffy::style::LengthPercentage::Length(60f32),
263 bottom: taffy::style::LengthPercentage::Length(60f32),
264 },
265 ..Default::default()
266 },
267 &[node0],
268 )
269 .unwrap();
270 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
271 println!("\nComputed tree:");
272 taffy.print_tree(node);
273 println!();
274 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
275 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
276 assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width);
277 assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height);
278 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
279 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
280 #[cfg(feature = "content_size")]
281 assert_eq!(
282 layout.scroll_width(),
283 0f32,
284 "scroll_width of node {:?}. Expected {}. Actual {}",
285 node,
286 0f32,
287 layout.scroll_width()
288 );
289 #[cfg(feature = "content_size")]
290 assert_eq!(
291 layout.scroll_height(),
292 0f32,
293 "scroll_height of node {:?}. Expected {}. Actual {}",
294 node,
295 0f32,
296 layout.scroll_height()
297 );
298 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
299 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
300 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width);
301 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
302 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
303 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
304 #[cfg(feature = "content_size")]
305 assert_eq!(
306 layout.scroll_width(),
307 0f32,
308 "scroll_width of node {:?}. Expected {}. Actual {}",
309 node0,
310 0f32,
311 layout.scroll_width()
312 );
313 #[cfg(feature = "content_size")]
314 assert_eq!(
315 layout.scroll_height(),
316 50f32,
317 "scroll_height of node {:?}. Expected {}. Actual {}",
318 node0,
319 50f32,
320 layout.scroll_height()
321 );
322 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
323 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
324 assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width);
325 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
326 assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x);
327 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
328 #[cfg(feature = "content_size")]
329 assert_eq!(
330 layout.scroll_width(),
331 0f32,
332 "scroll_width of node {:?}. Expected {}. Actual {}",
333 node00,
334 0f32,
335 layout.scroll_width()
336 );
337 #[cfg(feature = "content_size")]
338 assert_eq!(
339 layout.scroll_height(),
340 0f32,
341 "scroll_height of node {:?}. Expected {}. Actual {}",
342 node00,
343 0f32,
344 layout.scroll_height()
345 );
346 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
347 let layout @ Layout { size, location, .. } = taffy.layout(node01).unwrap();
348 assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node01, 256f32, size.width);
349 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01, 20f32, size.height);
350 assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node01, 32f32, location.x);
351 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01, 20f32, location.y);
352 #[cfg(feature = "content_size")]
353 assert_eq!(
354 layout.scroll_width(),
355 0f32,
356 "scroll_width of node {:?}. Expected {}. Actual {}",
357 node01,
358 0f32,
359 layout.scroll_width()
360 );
361 #[cfg(feature = "content_size")]
362 assert_eq!(
363 layout.scroll_height(),
364 0f32,
365 "scroll_height of node {:?}. Expected {}. Actual {}",
366 node01,
367 0f32,
368 layout.scroll_height()
369 );
370 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
371 let layout @ Layout { size, location, .. } = taffy.layout(node02).unwrap();
372 assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node02, 256f32, size.width);
373 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02, 20f32, size.height);
374 assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node02, 32f32, location.x);
375 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02, 40f32, location.y);
376 #[cfg(feature = "content_size")]
377 assert_eq!(
378 layout.scroll_width(),
379 0f32,
380 "scroll_width of node {:?}. Expected {}. Actual {}",
381 node02,
382 0f32,
383 layout.scroll_width()
384 );
385 #[cfg(feature = "content_size")]
386 assert_eq!(
387 layout.scroll_height(),
388 0f32,
389 "scroll_height of node {:?}. Expected {}. Actual {}",
390 node02,
391 0f32,
392 layout.scroll_height()
393 );
394}