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