⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/android_news_feed.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn android_news_feed() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node000000 = taffy
7 .new_leaf(taffy::style::Style {
8 align_content: Some(taffy::style::AlignContent::Stretch),
9 flex_shrink: 0f32,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::Length(120f32),
12 height: taffy::style::Dimension::Length(120f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node00000 = taffy
18 .new_with_children(
19 taffy::style::Style {
20 align_content: Some(taffy::style::AlignContent::Stretch),
21 flex_shrink: 0f32,
22 ..Default::default()
23 },
24 &[node000000],
25 )
26 .unwrap();
27 let node000010 = taffy
28 .new_leaf(taffy::style::Style {
29 align_content: Some(taffy::style::AlignContent::Stretch),
30 flex_shrink: 1f32,
31 ..Default::default()
32 })
33 .unwrap();
34 let node000011 = taffy
35 .new_leaf(taffy::style::Style {
36 align_content: Some(taffy::style::AlignContent::Stretch),
37 flex_shrink: 1f32,
38 ..Default::default()
39 })
40 .unwrap();
41 let node00001 = taffy
42 .new_with_children(
43 taffy::style::Style {
44 flex_direction: taffy::style::FlexDirection::Column,
45 align_content: Some(taffy::style::AlignContent::Stretch),
46 flex_shrink: 1f32,
47 margin: taffy::geometry::Rect {
48 left: zero(),
49 right: taffy::style::LengthPercentageAuto::Length(36f32),
50 top: zero(),
51 bottom: zero(),
52 },
53 padding: taffy::geometry::Rect {
54 left: taffy::style::LengthPercentage::Length(36f32),
55 right: taffy::style::LengthPercentage::Length(36f32),
56 top: taffy::style::LengthPercentage::Length(21f32),
57 bottom: taffy::style::LengthPercentage::Length(18f32),
58 },
59 ..Default::default()
60 },
61 &[node000010, node000011],
62 )
63 .unwrap();
64 let node0000 = taffy
65 .new_with_children(
66 taffy::style::Style {
67 align_items: Some(taffy::style::AlignItems::FlexStart),
68 align_content: Some(taffy::style::AlignContent::Stretch),
69 margin: taffy::geometry::Rect {
70 left: taffy::style::LengthPercentageAuto::Length(36f32),
71 right: zero(),
72 top: taffy::style::LengthPercentageAuto::Length(24f32),
73 bottom: zero(),
74 },
75 ..Default::default()
76 },
77 &[node00000, node00001],
78 )
79 .unwrap();
80 let node000 = taffy
81 .new_with_children(
82 taffy::style::Style {
83 flex_direction: taffy::style::FlexDirection::Column,
84 align_content: Some(taffy::style::AlignContent::Stretch),
85 ..Default::default()
86 },
87 &[node0000],
88 )
89 .unwrap();
90 let node001000 = taffy
91 .new_leaf(taffy::style::Style {
92 align_content: Some(taffy::style::AlignContent::Stretch),
93 flex_shrink: 0f32,
94 size: taffy::geometry::Size {
95 width: taffy::style::Dimension::Length(72f32),
96 height: taffy::style::Dimension::Length(72f32),
97 },
98 ..Default::default()
99 })
100 .unwrap();
101 let node00100 = taffy
102 .new_with_children(
103 taffy::style::Style {
104 align_content: Some(taffy::style::AlignContent::Stretch),
105 flex_shrink: 0f32,
106 ..Default::default()
107 },
108 &[node001000],
109 )
110 .unwrap();
111 let node001010 = taffy
112 .new_leaf(taffy::style::Style {
113 align_content: Some(taffy::style::AlignContent::Stretch),
114 flex_shrink: 1f32,
115 ..Default::default()
116 })
117 .unwrap();
118 let node001011 = taffy
119 .new_leaf(taffy::style::Style {
120 align_content: Some(taffy::style::AlignContent::Stretch),
121 flex_shrink: 1f32,
122 ..Default::default()
123 })
124 .unwrap();
125 let node00101 = taffy
126 .new_with_children(
127 taffy::style::Style {
128 flex_direction: taffy::style::FlexDirection::Column,
129 align_content: Some(taffy::style::AlignContent::Stretch),
130 flex_shrink: 1f32,
131 margin: taffy::geometry::Rect {
132 left: zero(),
133 right: taffy::style::LengthPercentageAuto::Length(36f32),
134 top: zero(),
135 bottom: zero(),
136 },
137 padding: taffy::geometry::Rect {
138 left: taffy::style::LengthPercentage::Length(36f32),
139 right: taffy::style::LengthPercentage::Length(36f32),
140 top: taffy::style::LengthPercentage::Length(21f32),
141 bottom: taffy::style::LengthPercentage::Length(18f32),
142 },
143 ..Default::default()
144 },
145 &[node001010, node001011],
146 )
147 .unwrap();
148 let node0010 = taffy
149 .new_with_children(
150 taffy::style::Style {
151 align_items: Some(taffy::style::AlignItems::FlexStart),
152 align_content: Some(taffy::style::AlignContent::Stretch),
153 margin: taffy::geometry::Rect {
154 left: taffy::style::LengthPercentageAuto::Length(174f32),
155 right: zero(),
156 top: taffy::style::LengthPercentageAuto::Length(24f32),
157 bottom: zero(),
158 },
159 ..Default::default()
160 },
161 &[node00100, node00101],
162 )
163 .unwrap();
164 let node001 = taffy
165 .new_with_children(
166 taffy::style::Style {
167 flex_direction: taffy::style::FlexDirection::Column,
168 align_content: Some(taffy::style::AlignContent::Stretch),
169 ..Default::default()
170 },
171 &[node0010],
172 )
173 .unwrap();
174 let node00 = taffy
175 .new_with_children(
176 taffy::style::Style {
177 flex_direction: taffy::style::FlexDirection::Column,
178 align_content: Some(taffy::style::AlignContent::Stretch),
179 ..Default::default()
180 },
181 &[node000, node001],
182 )
183 .unwrap();
184 let node0 = taffy
185 .new_with_children(
186 taffy::style::Style {
187 flex_direction: taffy::style::FlexDirection::Column,
188 flex_shrink: 0f32,
189 ..Default::default()
190 },
191 &[node00],
192 )
193 .unwrap();
194 let node = taffy
195 .new_with_children(
196 taffy::style::Style {
197 flex_direction: taffy::style::FlexDirection::Column,
198 align_content: Some(taffy::style::AlignContent::Stretch),
199 flex_shrink: 0f32,
200 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(1080f32), height: auto() },
201 ..Default::default()
202 },
203 &[node0],
204 )
205 .unwrap();
206 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
207 println!("\nComputed tree:");
208 taffy::util::print_tree(&taffy, node);
209 println!();
210 let Layout { size, location, .. } = taffy.layout(node).unwrap();
211 assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node, 1080f32, size.width);
212 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height);
213 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
214 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
215 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
216 assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node0, 1080f32, size.width);
217 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node0, 240f32, size.height);
218 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
219 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
220 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
221 assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node00, 1080f32, size.width);
222 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node00, 240f32, size.height);
223 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
224 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
225 let Layout { size, location, .. } = taffy.layout(node000).unwrap();
226 assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node000, 1080f32, size.width);
227 assert_eq!(size.height, 144f32, "height of node {:?}. Expected {}. Actual {}", node000, 144f32, size.height);
228 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000, 0f32, location.x);
229 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000, 0f32, location.y);
230 let Layout { size, location, .. } = taffy.layout(node0000).unwrap();
231 assert_eq!(size.width, 1044f32, "width of node {:?}. Expected {}. Actual {}", node0000, 1044f32, size.width);
232 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0000, 120f32, size.height);
233 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node0000, 36f32, location.x);
234 assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0000, 24f32, location.y);
235 let Layout { size, location, .. } = taffy.layout(node00000).unwrap();
236 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.width);
237 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node00000, 120f32, size.height);
238 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.x);
239 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00000, 0f32, location.y);
240 let Layout { size, location, .. } = taffy.layout(node000000).unwrap();
241 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.width);
242 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node000000, 120f32, size.height);
243 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.x);
244 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node000000, 0f32, location.y);
245 let Layout { size, location, .. } = taffy.layout(node00001).unwrap();
246 assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00001, 72f32, size.width);
247 assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00001, 39f32, size.height);
248 assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node00001, 120f32, location.x);
249 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00001, 0f32, location.y);
250 let Layout { size, location, .. } = taffy.layout(node000010).unwrap();
251 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.width);
252 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000010, 0f32, size.height);
253 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000010, 36f32, location.x);
254 assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000010, 21f32, location.y);
255 let Layout { size, location, .. } = taffy.layout(node000011).unwrap();
256 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.width);
257 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node000011, 0f32, size.height);
258 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node000011, 36f32, location.x);
259 assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node000011, 21f32, location.y);
260 let Layout { size, location, .. } = taffy.layout(node001).unwrap();
261 assert_eq!(size.width, 1080f32, "width of node {:?}. Expected {}. Actual {}", node001, 1080f32, size.width);
262 assert_eq!(size.height, 96f32, "height of node {:?}. Expected {}. Actual {}", node001, 96f32, size.height);
263 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001, 0f32, location.x);
264 assert_eq!(location.y, 144f32, "y of node {:?}. Expected {}. Actual {}", node001, 144f32, location.y);
265 let Layout { size, location, .. } = taffy.layout(node0010).unwrap();
266 assert_eq!(size.width, 906f32, "width of node {:?}. Expected {}. Actual {}", node0010, 906f32, size.width);
267 assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node0010, 72f32, size.height);
268 assert_eq!(location.x, 174f32, "x of node {:?}. Expected {}. Actual {}", node0010, 174f32, location.x);
269 assert_eq!(location.y, 24f32, "y of node {:?}. Expected {}. Actual {}", node0010, 24f32, location.y);
270 let Layout { size, location, .. } = taffy.layout(node00100).unwrap();
271 assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.width);
272 assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node00100, 72f32, size.height);
273 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.x);
274 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00100, 0f32, location.y);
275 let Layout { size, location, .. } = taffy.layout(node001000).unwrap();
276 assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.width);
277 assert_eq!(size.height, 72f32, "height of node {:?}. Expected {}. Actual {}", node001000, 72f32, size.height);
278 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.x);
279 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node001000, 0f32, location.y);
280 let Layout { size, location, .. } = taffy.layout(node00101).unwrap();
281 assert_eq!(size.width, 72f32, "width of node {:?}. Expected {}. Actual {}", node00101, 72f32, size.width);
282 assert_eq!(size.height, 39f32, "height of node {:?}. Expected {}. Actual {}", node00101, 39f32, size.height);
283 assert_eq!(location.x, 72f32, "x of node {:?}. Expected {}. Actual {}", node00101, 72f32, location.x);
284 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00101, 0f32, location.y);
285 let Layout { size, location, .. } = taffy.layout(node001010).unwrap();
286 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.width);
287 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001010, 0f32, size.height);
288 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001010, 36f32, location.x);
289 assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001010, 21f32, location.y);
290 let Layout { size, location, .. } = taffy.layout(node001011).unwrap();
291 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.width);
292 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node001011, 0f32, size.height);
293 assert_eq!(location.x, 36f32, "x of node {:?}. Expected {}. Actual {}", node001011, 36f32, location.x);
294 assert_eq!(location.y, 21f32, "y of node {:?}. Expected {}. Actual {}", node001011, 21f32, location.y);
295}