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