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