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