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