⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/rounding_inner_node_controversy_combined.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn rounding_inner_node_controversy_combined() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_grow: 1f32,
9 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
10 ..Default::default()
11 })
12 .unwrap();
13 let node10 = taffy
14 .new_leaf(taffy::style::Style {
15 flex_grow: 1f32,
16 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
17 ..Default::default()
18 })
19 .unwrap();
20 let node110 = taffy
21 .new_leaf(taffy::style::Style {
22 flex_grow: 1f32,
23 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
24 ..Default::default()
25 })
26 .unwrap();
27 let node11 = taffy
28 .new_with_children(
29 taffy::style::Style {
30 flex_direction: taffy::style::FlexDirection::Column,
31 flex_grow: 1f32,
32 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
33 ..Default::default()
34 },
35 &[node110],
36 )
37 .unwrap();
38 let node12 = taffy
39 .new_leaf(taffy::style::Style {
40 flex_grow: 1f32,
41 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
42 ..Default::default()
43 })
44 .unwrap();
45 let node1 = taffy
46 .new_with_children(
47 taffy::style::Style {
48 flex_direction: taffy::style::FlexDirection::Column,
49 flex_grow: 1f32,
50 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
51 ..Default::default()
52 },
53 &[node10, node11, node12],
54 )
55 .unwrap();
56 let node2 = taffy
57 .new_leaf(taffy::style::Style {
58 flex_grow: 1f32,
59 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
60 ..Default::default()
61 })
62 .unwrap();
63 let node = taffy
64 .new_with_children(
65 taffy::style::Style {
66 size: taffy::geometry::Size {
67 width: taffy::style::Dimension::Length(640f32),
68 height: taffy::style::Dimension::Length(320f32),
69 },
70 ..Default::default()
71 },
72 &[node0, node1, node2],
73 )
74 .unwrap();
75 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
76 println!("\nComputed tree:");
77 taffy.print_tree(node);
78 println!();
79 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
80 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
81 assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node, 640f32, size.width);
82 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
85 #[cfg(feature = "content_size")]
86 assert_eq!(
87 layout.scroll_width(),
88 0f32,
89 "scroll_width of node {:?}. Expected {}. Actual {}",
90 node,
91 0f32,
92 layout.scroll_width()
93 );
94 #[cfg(feature = "content_size")]
95 assert_eq!(
96 layout.scroll_height(),
97 0f32,
98 "scroll_height of node {:?}. Expected {}. Actual {}",
99 node,
100 0f32,
101 layout.scroll_height()
102 );
103 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
104 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
105 assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0, 213f32, size.width);
106 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height);
107 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
108 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
109 #[cfg(feature = "content_size")]
110 assert_eq!(
111 layout.scroll_width(),
112 0f32,
113 "scroll_width of node {:?}. Expected {}. Actual {}",
114 node0,
115 0f32,
116 layout.scroll_width()
117 );
118 #[cfg(feature = "content_size")]
119 assert_eq!(
120 layout.scroll_height(),
121 0f32,
122 "scroll_height of node {:?}. Expected {}. Actual {}",
123 node0,
124 0f32,
125 layout.scroll_height()
126 );
127 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
128 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
129 assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1, 214f32, size.width);
130 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1, 320f32, size.height);
131 assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1, 213f32, location.x);
132 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
133 #[cfg(feature = "content_size")]
134 assert_eq!(
135 layout.scroll_width(),
136 0f32,
137 "scroll_width of node {:?}. Expected {}. Actual {}",
138 node1,
139 0f32,
140 layout.scroll_width()
141 );
142 #[cfg(feature = "content_size")]
143 assert_eq!(
144 layout.scroll_height(),
145 0f32,
146 "scroll_height of node {:?}. Expected {}. Actual {}",
147 node1,
148 0f32,
149 layout.scroll_height()
150 );
151 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
152 let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
153 assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10, 214f32, size.width);
154 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10, 107f32, size.height);
155 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
156 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
157 #[cfg(feature = "content_size")]
158 assert_eq!(
159 layout.scroll_width(),
160 0f32,
161 "scroll_width of node {:?}. Expected {}. Actual {}",
162 node10,
163 0f32,
164 layout.scroll_width()
165 );
166 #[cfg(feature = "content_size")]
167 assert_eq!(
168 layout.scroll_height(),
169 0f32,
170 "scroll_height of node {:?}. Expected {}. Actual {}",
171 node10,
172 0f32,
173 layout.scroll_height()
174 );
175 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
176 let layout @ Layout { size, location, .. } = taffy.layout(node11).unwrap();
177 assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11, 214f32, size.width);
178 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11, 106f32, size.height);
179 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x);
180 assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11, 107f32, location.y);
181 #[cfg(feature = "content_size")]
182 assert_eq!(
183 layout.scroll_width(),
184 0f32,
185 "scroll_width of node {:?}. Expected {}. Actual {}",
186 node11,
187 0f32,
188 layout.scroll_width()
189 );
190 #[cfg(feature = "content_size")]
191 assert_eq!(
192 layout.scroll_height(),
193 0f32,
194 "scroll_height of node {:?}. Expected {}. Actual {}",
195 node11,
196 0f32,
197 layout.scroll_height()
198 );
199 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
200 let layout @ Layout { size, location, .. } = taffy.layout(node110).unwrap();
201 assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110, 214f32, size.width);
202 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110, 106f32, size.height);
203 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110, 0f32, location.x);
204 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110, 0f32, location.y);
205 #[cfg(feature = "content_size")]
206 assert_eq!(
207 layout.scroll_width(),
208 0f32,
209 "scroll_width of node {:?}. Expected {}. Actual {}",
210 node110,
211 0f32,
212 layout.scroll_width()
213 );
214 #[cfg(feature = "content_size")]
215 assert_eq!(
216 layout.scroll_height(),
217 0f32,
218 "scroll_height of node {:?}. Expected {}. Actual {}",
219 node110,
220 0f32,
221 layout.scroll_height()
222 );
223 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
224 let layout @ Layout { size, location, .. } = taffy.layout(node12).unwrap();
225 assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12, 214f32, size.width);
226 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12, 107f32, size.height);
227 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x);
228 assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12, 213f32, location.y);
229 #[cfg(feature = "content_size")]
230 assert_eq!(
231 layout.scroll_width(),
232 0f32,
233 "scroll_width of node {:?}. Expected {}. Actual {}",
234 node12,
235 0f32,
236 layout.scroll_width()
237 );
238 #[cfg(feature = "content_size")]
239 assert_eq!(
240 layout.scroll_height(),
241 0f32,
242 "scroll_height of node {:?}. Expected {}. Actual {}",
243 node12,
244 0f32,
245 layout.scroll_height()
246 );
247 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
248 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
249 assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2, 213f32, size.width);
250 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2, 320f32, size.height);
251 assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2, 427f32, location.x);
252 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
253 #[cfg(feature = "content_size")]
254 assert_eq!(
255 layout.scroll_width(),
256 0f32,
257 "scroll_width of node {:?}. Expected {}. Actual {}",
258 node2,
259 0f32,
260 layout.scroll_width()
261 );
262 #[cfg(feature = "content_size")]
263 assert_eq!(
264 layout.scroll_height(),
265 0f32,
266 "scroll_height of node {:?}. Expected {}. Actual {}",
267 node2,
268 0f32,
269 layout.scroll_height()
270 );
271}