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