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