⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/align_content_stretch_row_with_children.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_content_stretch_row_with_children__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 flex_grow: 1f32,
10 flex_shrink: 1f32,
11 flex_basis: taffy::style::Dimension::from_percent(0f32),
12 ..Default::default()
13 })
14 .unwrap();
15 let node0 = taffy
16 .new_with_children(
17 taffy::style::Style {
18 flex_direction: taffy::style::FlexDirection::Column,
19 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
20 ..Default::default()
21 },
22 &[node00],
23 )
24 .unwrap();
25 let node1 = taffy
26 .new_leaf(taffy::style::Style {
27 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
28 ..Default::default()
29 })
30 .unwrap();
31 let node2 = taffy
32 .new_leaf(taffy::style::Style {
33 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
34 ..Default::default()
35 })
36 .unwrap();
37 let node3 = taffy
38 .new_leaf(taffy::style::Style {
39 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
40 ..Default::default()
41 })
42 .unwrap();
43 let node4 = taffy
44 .new_leaf(taffy::style::Style {
45 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
46 ..Default::default()
47 })
48 .unwrap();
49 let node = taffy
50 .new_with_children(
51 taffy::style::Style {
52 flex_wrap: taffy::style::FlexWrap::Wrap,
53 align_content: Some(taffy::style::AlignContent::Stretch),
54 size: taffy::geometry::Size {
55 width: taffy::style::Dimension::from_length(150f32),
56 height: taffy::style::Dimension::from_length(100f32),
57 },
58 ..Default::default()
59 },
60 &[node0, node1, node2, node3, node4],
61 )
62 .unwrap();
63 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
64 println!("\nComputed tree:");
65 taffy.print_tree(node);
66 println!();
67 let layout = taffy.layout(node).unwrap();
68 let Layout { size, location, .. } = layout;
69 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
70 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
71 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
72 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
73 let layout = taffy.layout(node0).unwrap();
74 let Layout { size, location, .. } = layout;
75 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
76 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
79 let layout = taffy.layout(node00).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
82 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
85 let layout = taffy.layout(node1).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
88 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height);
89 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
90 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
91 let layout = taffy.layout(node2).unwrap();
92 let Layout { size, location, .. } = layout;
93 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
94 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height);
95 assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x);
96 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
97 let layout = taffy.layout(node3).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
100 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
102 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y);
103 let layout = taffy.layout(node4).unwrap();
104 let Layout { size, location, .. } = layout;
105 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
106 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height);
107 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x);
108 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y);
109}
110
111#[test]
112#[allow(non_snake_case)]
113fn align_content_stretch_row_with_children__content_box() {
114 #[allow(unused_imports)]
115 use taffy::{prelude::*, Layout};
116 let mut taffy = crate::new_test_tree();
117 let node00 = taffy
118 .new_leaf(taffy::style::Style {
119 box_sizing: taffy::style::BoxSizing::ContentBox,
120 flex_grow: 1f32,
121 flex_shrink: 1f32,
122 flex_basis: taffy::style::Dimension::from_percent(0f32),
123 ..Default::default()
124 })
125 .unwrap();
126 let node0 = taffy
127 .new_with_children(
128 taffy::style::Style {
129 box_sizing: taffy::style::BoxSizing::ContentBox,
130 flex_direction: taffy::style::FlexDirection::Column,
131 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
132 ..Default::default()
133 },
134 &[node00],
135 )
136 .unwrap();
137 let node1 = taffy
138 .new_leaf(taffy::style::Style {
139 box_sizing: taffy::style::BoxSizing::ContentBox,
140 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
141 ..Default::default()
142 })
143 .unwrap();
144 let node2 = taffy
145 .new_leaf(taffy::style::Style {
146 box_sizing: taffy::style::BoxSizing::ContentBox,
147 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
148 ..Default::default()
149 })
150 .unwrap();
151 let node3 = taffy
152 .new_leaf(taffy::style::Style {
153 box_sizing: taffy::style::BoxSizing::ContentBox,
154 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
155 ..Default::default()
156 })
157 .unwrap();
158 let node4 = taffy
159 .new_leaf(taffy::style::Style {
160 box_sizing: taffy::style::BoxSizing::ContentBox,
161 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(50f32), height: auto() },
162 ..Default::default()
163 })
164 .unwrap();
165 let node = taffy
166 .new_with_children(
167 taffy::style::Style {
168 box_sizing: taffy::style::BoxSizing::ContentBox,
169 flex_wrap: taffy::style::FlexWrap::Wrap,
170 align_content: Some(taffy::style::AlignContent::Stretch),
171 size: taffy::geometry::Size {
172 width: taffy::style::Dimension::from_length(150f32),
173 height: taffy::style::Dimension::from_length(100f32),
174 },
175 ..Default::default()
176 },
177 &[node0, node1, node2, node3, node4],
178 )
179 .unwrap();
180 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
181 println!("\nComputed tree:");
182 taffy.print_tree(node);
183 println!();
184 let layout = taffy.layout(node).unwrap();
185 let Layout { size, location, .. } = layout;
186 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
187 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
188 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
189 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
190 let layout = taffy.layout(node0).unwrap();
191 let Layout { size, location, .. } = layout;
192 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
193 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
194 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
195 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
196 let layout = taffy.layout(node00).unwrap();
197 let Layout { size, location, .. } = layout;
198 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
199 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node00, 50f32, size.height);
200 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
201 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
202 let layout = taffy.layout(node1).unwrap();
203 let Layout { size, location, .. } = layout;
204 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
205 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height);
206 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
207 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
208 let layout = taffy.layout(node2).unwrap();
209 let Layout { size, location, .. } = layout;
210 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
211 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height);
212 assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x);
213 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
214 let layout = taffy.layout(node3).unwrap();
215 let Layout { size, location, .. } = layout;
216 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
217 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height);
218 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
219 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y);
220 let layout = taffy.layout(node4).unwrap();
221 let Layout { size, location, .. } = layout;
222 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
223 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height);
224 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x);
225 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y);
226}