⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/align_baseline_child_multiline_override.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_baseline_child_multiline_override__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::from_length(50f32),
11 height: taffy::style::Dimension::from_length(60f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node10 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::from_length(25f32),
20 height: taffy::style::Dimension::from_length(20f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node11 = taffy
26 .new_leaf(taffy::style::Style {
27 align_self: Some(taffy::style::AlignSelf::Baseline),
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::from_length(25f32),
30 height: taffy::style::Dimension::from_length(10f32),
31 },
32 ..Default::default()
33 })
34 .unwrap();
35 let node12 = taffy
36 .new_leaf(taffy::style::Style {
37 size: taffy::geometry::Size {
38 width: taffy::style::Dimension::from_length(25f32),
39 height: taffy::style::Dimension::from_length(20f32),
40 },
41 ..Default::default()
42 })
43 .unwrap();
44 let node13 = taffy
45 .new_leaf(taffy::style::Style {
46 align_self: Some(taffy::style::AlignSelf::Baseline),
47 size: taffy::geometry::Size {
48 width: taffy::style::Dimension::from_length(25f32),
49 height: taffy::style::Dimension::from_length(10f32),
50 },
51 ..Default::default()
52 })
53 .unwrap();
54 let node1 = taffy
55 .new_with_children(
56 taffy::style::Style {
57 flex_wrap: taffy::style::FlexWrap::Wrap,
58 size: taffy::geometry::Size {
59 width: taffy::style::Dimension::from_length(50f32),
60 height: taffy::style::Dimension::from_length(25f32),
61 },
62 ..Default::default()
63 },
64 &[node10, node11, node12, node13],
65 )
66 .unwrap();
67 let node = taffy
68 .new_with_children(
69 taffy::style::Style {
70 align_items: Some(taffy::style::AlignItems::Baseline),
71 size: taffy::geometry::Size {
72 width: taffy::style::Dimension::from_length(100f32),
73 height: taffy::style::Dimension::from_length(100f32),
74 },
75 ..Default::default()
76 },
77 &[node0, node1],
78 )
79 .unwrap();
80 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
81 println!("\nComputed tree:");
82 taffy.print_tree(node);
83 println!();
84 let layout = taffy.layout(node).unwrap();
85 let Layout { size, location, .. } = layout;
86 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
87 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
88 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
89 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
90 let layout = taffy.layout(node0).unwrap();
91 let Layout { size, location, .. } = layout;
92 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
93 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
94 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
95 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
96 let layout = taffy.layout(node1).unwrap();
97 let Layout { size, location, .. } = layout;
98 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
99 assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height);
100 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
101 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
102 let layout = taffy.layout(node10).unwrap();
103 let Layout { size, location, .. } = layout;
104 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width);
105 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
106 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
107 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
108 let layout = taffy.layout(node11).unwrap();
109 let Layout { size, location, .. } = layout;
110 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width);
111 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height);
112 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x);
113 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y);
114 let layout = taffy.layout(node12).unwrap();
115 let Layout { size, location, .. } = layout;
116 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width);
117 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x);
119 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y);
120 let layout = taffy.layout(node13).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width);
123 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height);
124 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x);
125 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y);
126}
127
128#[test]
129#[allow(non_snake_case)]
130fn align_baseline_child_multiline_override__content_box() {
131 #[allow(unused_imports)]
132 use taffy::{prelude::*, Layout};
133 let mut taffy = crate::new_test_tree();
134 let node0 = taffy
135 .new_leaf(taffy::style::Style {
136 box_sizing: taffy::style::BoxSizing::ContentBox,
137 size: taffy::geometry::Size {
138 width: taffy::style::Dimension::from_length(50f32),
139 height: taffy::style::Dimension::from_length(60f32),
140 },
141 ..Default::default()
142 })
143 .unwrap();
144 let node10 = taffy
145 .new_leaf(taffy::style::Style {
146 box_sizing: taffy::style::BoxSizing::ContentBox,
147 size: taffy::geometry::Size {
148 width: taffy::style::Dimension::from_length(25f32),
149 height: taffy::style::Dimension::from_length(20f32),
150 },
151 ..Default::default()
152 })
153 .unwrap();
154 let node11 = taffy
155 .new_leaf(taffy::style::Style {
156 box_sizing: taffy::style::BoxSizing::ContentBox,
157 align_self: Some(taffy::style::AlignSelf::Baseline),
158 size: taffy::geometry::Size {
159 width: taffy::style::Dimension::from_length(25f32),
160 height: taffy::style::Dimension::from_length(10f32),
161 },
162 ..Default::default()
163 })
164 .unwrap();
165 let node12 = taffy
166 .new_leaf(taffy::style::Style {
167 box_sizing: taffy::style::BoxSizing::ContentBox,
168 size: taffy::geometry::Size {
169 width: taffy::style::Dimension::from_length(25f32),
170 height: taffy::style::Dimension::from_length(20f32),
171 },
172 ..Default::default()
173 })
174 .unwrap();
175 let node13 = taffy
176 .new_leaf(taffy::style::Style {
177 box_sizing: taffy::style::BoxSizing::ContentBox,
178 align_self: Some(taffy::style::AlignSelf::Baseline),
179 size: taffy::geometry::Size {
180 width: taffy::style::Dimension::from_length(25f32),
181 height: taffy::style::Dimension::from_length(10f32),
182 },
183 ..Default::default()
184 })
185 .unwrap();
186 let node1 = taffy
187 .new_with_children(
188 taffy::style::Style {
189 box_sizing: taffy::style::BoxSizing::ContentBox,
190 flex_wrap: taffy::style::FlexWrap::Wrap,
191 size: taffy::geometry::Size {
192 width: taffy::style::Dimension::from_length(50f32),
193 height: taffy::style::Dimension::from_length(25f32),
194 },
195 ..Default::default()
196 },
197 &[node10, node11, node12, node13],
198 )
199 .unwrap();
200 let node = taffy
201 .new_with_children(
202 taffy::style::Style {
203 box_sizing: taffy::style::BoxSizing::ContentBox,
204 align_items: Some(taffy::style::AlignItems::Baseline),
205 size: taffy::geometry::Size {
206 width: taffy::style::Dimension::from_length(100f32),
207 height: taffy::style::Dimension::from_length(100f32),
208 },
209 ..Default::default()
210 },
211 &[node0, node1],
212 )
213 .unwrap();
214 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
215 println!("\nComputed tree:");
216 taffy.print_tree(node);
217 println!();
218 let layout = taffy.layout(node).unwrap();
219 let Layout { size, location, .. } = layout;
220 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
221 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
222 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
223 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
224 let layout = taffy.layout(node0).unwrap();
225 let Layout { size, location, .. } = layout;
226 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
227 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
228 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
229 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
230 let layout = taffy.layout(node1).unwrap();
231 let Layout { size, location, .. } = layout;
232 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
233 assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height);
234 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
235 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
236 let layout = taffy.layout(node10).unwrap();
237 let Layout { size, location, .. } = layout;
238 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width);
239 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
240 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
241 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
242 let layout = taffy.layout(node11).unwrap();
243 let Layout { size, location, .. } = layout;
244 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width);
245 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height);
246 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x);
247 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y);
248 let layout = taffy.layout(node12).unwrap();
249 let Layout { size, location, .. } = layout;
250 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width);
251 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height);
252 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x);
253 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y);
254 let layout = taffy.layout(node13).unwrap();
255 let Layout { size, location, .. } = layout;
256 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width);
257 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height);
258 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x);
259 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y);
260}