⎇ 477ff4aff498cbae4cdfbf0cda1ee5b04c784f08
tests/generated/flex/align_baseline_child_multiline_override.rs
History
Who touched what
raw
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn align_baseline_child_multiline_override() {
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(60f32),
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(25f32),
19 height: taffy::style::Dimension::Length(20f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node11 = taffy
25 .new_leaf(taffy::style::Style {
26 align_self: Some(taffy::style::AlignSelf::Baseline),
27 size: taffy::geometry::Size {
28 width: taffy::style::Dimension::Length(25f32),
29 height: taffy::style::Dimension::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::Length(25f32),
38 height: taffy::style::Dimension::Length(20f32),
39 },
40 ..Default::default()
41 })
42 .unwrap();
43 let node13 = taffy
44 .new_leaf(taffy::style::Style {
45 align_self: Some(taffy::style::AlignSelf::Baseline),
46 size: taffy::geometry::Size {
47 width: taffy::style::Dimension::Length(25f32),
48 height: taffy::style::Dimension::Length(10f32),
49 },
50 ..Default::default()
51 })
52 .unwrap();
53 let node1 = taffy
54 .new_with_children(
55 taffy::style::Style {
56 flex_wrap: taffy::style::FlexWrap::Wrap,
57 size: taffy::geometry::Size {
58 width: taffy::style::Dimension::Length(50f32),
59 height: taffy::style::Dimension::Length(25f32),
60 },
61 ..Default::default()
62 },
63 &[node10, node11, node12, node13],
64 )
65 .unwrap();
66 let node = taffy
67 .new_with_children(
68 taffy::style::Style {
69 align_items: Some(taffy::style::AlignItems::Baseline),
70 size: taffy::geometry::Size {
71 width: taffy::style::Dimension::Length(100f32),
72 height: taffy::style::Dimension::Length(100f32),
73 },
74 ..Default::default()
75 },
76 &[node0, node1],
77 )
78 .unwrap();
79 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
80 println!("\nComputed tree:");
81 taffy.print_tree(node);
82 println!();
83 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
84 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
85 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
86 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
87 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
88 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
89 #[cfg(feature = "content_size")]
90 assert_eq!(
91 layout.scroll_width(),
92 0f32,
93 "scroll_width of node {:?}. Expected {}. Actual {}",
94 node,
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 node,
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(node0).unwrap();
109 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
110 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
111 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
112 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
113 #[cfg(feature = "content_size")]
114 assert_eq!(
115 layout.scroll_width(),
116 0f32,
117 "scroll_width of node {:?}. Expected {}. Actual {}",
118 node0,
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 node0,
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(node1).unwrap();
133 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
134 assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1, 25f32, size.height);
135 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
136 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
137 #[cfg(feature = "content_size")]
138 assert_eq!(
139 layout.scroll_width(),
140 0f32,
141 "scroll_width of node {:?}. Expected {}. Actual {}",
142 node1,
143 0f32,
144 layout.scroll_width()
145 );
146 #[cfg(feature = "content_size")]
147 assert_eq!(
148 layout.scroll_height(),
149 15f32,
150 "scroll_height of node {:?}. Expected {}. Actual {}",
151 node1,
152 15f32,
153 layout.scroll_height()
154 );
155 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
156 let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
157 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10, 25f32, size.width);
158 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10, 20f32, size.height);
159 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
160 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
161 #[cfg(feature = "content_size")]
162 assert_eq!(
163 layout.scroll_width(),
164 0f32,
165 "scroll_width of node {:?}. Expected {}. Actual {}",
166 node10,
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 node10,
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(node11).unwrap();
181 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11, 25f32, size.width);
182 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11, 10f32, size.height);
183 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11, 25f32, location.x);
184 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11, 0f32, location.y);
185 #[cfg(feature = "content_size")]
186 assert_eq!(
187 layout.scroll_width(),
188 0f32,
189 "scroll_width of node {:?}. Expected {}. Actual {}",
190 node11,
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 node11,
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(node12).unwrap();
205 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12, 25f32, size.width);
206 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12, 20f32, size.height);
207 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x);
208 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12, 20f32, location.y);
209 #[cfg(feature = "content_size")]
210 assert_eq!(
211 layout.scroll_width(),
212 0f32,
213 "scroll_width of node {:?}. Expected {}. Actual {}",
214 node12,
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 node12,
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(node13).unwrap();
229 assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13, 25f32, size.width);
230 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13, 10f32, size.height);
231 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13, 25f32, location.x);
232 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13, 20f32, location.y);
233 #[cfg(feature = "content_size")]
234 assert_eq!(
235 layout.scroll_width(),
236 0f32,
237 "scroll_width of node {:?}. Expected {}. Actual {}",
238 node13,
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 node13,
248 0f32,
249 layout.scroll_height()
250 );
251}