⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/grid/grid_align_content_start_negative_space_gap.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 grid_align_content_start_negative_space_gap__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
9 let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
10 let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
11 let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
12 let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
13 let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
14 let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
15 let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 display: taffy::style::Display::Grid,
20 align_content: Some(taffy::style::AlignContent::Start),
21 justify_content: Some(taffy::style::JustifyContent::Center),
22 gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) },
23 grid_template_rows: vec![length(40f32), length(40f32), length(40f32)],
24 grid_template_columns: vec![length(20f32), length(20f32), length(20f32)],
25 size: taffy::geometry::Size {
26 width: taffy::style::Dimension::from_length(120f32),
27 height: taffy::style::Dimension::from_length(120f32),
28 },
29 ..Default::default()
30 },
31 &[node00, node01, node02, node03, node04, node05, node06, node07, node08],
32 )
33 .unwrap();
34 let node = taffy
35 .new_with_children(
36 taffy::style::Style {
37 display: taffy::style::Display::Grid,
38 size: taffy::geometry::Size {
39 width: taffy::style::Dimension::from_length(240f32),
40 height: taffy::style::Dimension::from_length(240f32),
41 },
42 border: taffy::geometry::Rect {
43 left: length(60f32),
44 right: length(60f32),
45 top: length(60f32),
46 bottom: length(60f32),
47 },
48 ..Default::default()
49 },
50 &[node0],
51 )
52 .unwrap();
53 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
54 println!("\nComputed tree:");
55 taffy.print_tree(node);
56 println!();
57 let layout = taffy.layout(node).unwrap();
58 let Layout { size, location, .. } = layout;
59 assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node, 240f32, size.width);
60 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node, 240f32, size.height);
61 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
63 let layout = taffy.layout(node0).unwrap();
64 let Layout { size, location, .. } = layout;
65 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width);
66 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height);
67 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
68 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
69 let layout = taffy.layout(node00).unwrap();
70 let Layout { size, location, .. } = layout;
71 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width);
72 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height);
73 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
74 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
75 let layout = taffy.layout(node01).unwrap();
76 let Layout { size, location, .. } = layout;
77 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width);
78 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height);
79 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x);
80 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y);
81 let layout = taffy.layout(node02).unwrap();
82 let Layout { size, location, .. } = layout;
83 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width);
84 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height);
85 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x);
86 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y);
87 let layout = taffy.layout(node03).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width);
90 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height);
91 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x);
92 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y);
93 let layout = taffy.layout(node04).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width);
96 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height);
97 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x);
98 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y);
99 let layout = taffy.layout(node05).unwrap();
100 let Layout { size, location, .. } = layout;
101 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width);
102 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height);
103 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x);
104 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y);
105 let layout = taffy.layout(node06).unwrap();
106 let Layout { size, location, .. } = layout;
107 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width);
108 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height);
109 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x);
110 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y);
111 let layout = taffy.layout(node07).unwrap();
112 let Layout { size, location, .. } = layout;
113 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width);
114 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height);
115 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x);
116 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y);
117 let layout = taffy.layout(node08).unwrap();
118 let Layout { size, location, .. } = layout;
119 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width);
120 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height);
121 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x);
122 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y);
123}
124
125#[test]
126#[allow(non_snake_case)]
127fn grid_align_content_start_negative_space_gap__content_box() {
128 #[allow(unused_imports)]
129 use taffy::{prelude::*, Layout};
130 let mut taffy = crate::new_test_tree();
131 let node00 = taffy
132 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
133 .unwrap();
134 let node01 = taffy
135 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
136 .unwrap();
137 let node02 = taffy
138 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
139 .unwrap();
140 let node03 = taffy
141 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
142 .unwrap();
143 let node04 = taffy
144 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
145 .unwrap();
146 let node05 = taffy
147 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
148 .unwrap();
149 let node06 = taffy
150 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
151 .unwrap();
152 let node07 = taffy
153 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
154 .unwrap();
155 let node08 = taffy
156 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
157 .unwrap();
158 let node0 = taffy
159 .new_with_children(
160 taffy::style::Style {
161 display: taffy::style::Display::Grid,
162 box_sizing: taffy::style::BoxSizing::ContentBox,
163 align_content: Some(taffy::style::AlignContent::Start),
164 justify_content: Some(taffy::style::JustifyContent::Center),
165 gap: taffy::geometry::Size { width: length(10f32), height: length(10f32) },
166 grid_template_rows: vec![length(40f32), length(40f32), length(40f32)],
167 grid_template_columns: vec![length(20f32), length(20f32), length(20f32)],
168 size: taffy::geometry::Size {
169 width: taffy::style::Dimension::from_length(120f32),
170 height: taffy::style::Dimension::from_length(120f32),
171 },
172 ..Default::default()
173 },
174 &[node00, node01, node02, node03, node04, node05, node06, node07, node08],
175 )
176 .unwrap();
177 let node = taffy
178 .new_with_children(
179 taffy::style::Style {
180 display: taffy::style::Display::Grid,
181 box_sizing: taffy::style::BoxSizing::ContentBox,
182 size: taffy::geometry::Size {
183 width: taffy::style::Dimension::from_length(240f32),
184 height: taffy::style::Dimension::from_length(240f32),
185 },
186 border: taffy::geometry::Rect {
187 left: length(60f32),
188 right: length(60f32),
189 top: length(60f32),
190 bottom: length(60f32),
191 },
192 ..Default::default()
193 },
194 &[node0],
195 )
196 .unwrap();
197 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
198 println!("\nComputed tree:");
199 taffy.print_tree(node);
200 println!();
201 let layout = taffy.layout(node).unwrap();
202 let Layout { size, location, .. } = layout;
203 assert_eq!(size.width, 360f32, "width of node {:?}. Expected {}. Actual {}", node, 360f32, size.width);
204 assert_eq!(size.height, 360f32, "height of node {:?}. Expected {}. Actual {}", node, 360f32, size.height);
205 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
206 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
207 let layout = taffy.layout(node0).unwrap();
208 let Layout { size, location, .. } = layout;
209 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0, 120f32, size.width);
210 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0, 120f32, size.height);
211 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
212 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
213 let layout = taffy.layout(node00).unwrap();
214 let Layout { size, location, .. } = layout;
215 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width);
216 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00, 40f32, size.height);
217 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
218 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
219 let layout = taffy.layout(node01).unwrap();
220 let Layout { size, location, .. } = layout;
221 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01, 20f32, size.width);
222 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01, 40f32, size.height);
223 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01, 50f32, location.x);
224 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01, 0f32, location.y);
225 let layout = taffy.layout(node02).unwrap();
226 let Layout { size, location, .. } = layout;
227 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02, 20f32, size.width);
228 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02, 40f32, size.height);
229 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02, 80f32, location.x);
230 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node02, 0f32, location.y);
231 let layout = taffy.layout(node03).unwrap();
232 let Layout { size, location, .. } = layout;
233 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03, 20f32, size.width);
234 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03, 40f32, size.height);
235 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03, 20f32, location.x);
236 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node03, 50f32, location.y);
237 let layout = taffy.layout(node04).unwrap();
238 let Layout { size, location, .. } = layout;
239 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04, 20f32, size.width);
240 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04, 40f32, size.height);
241 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04, 50f32, location.x);
242 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node04, 50f32, location.y);
243 let layout = taffy.layout(node05).unwrap();
244 let Layout { size, location, .. } = layout;
245 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05, 20f32, size.width);
246 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05, 40f32, size.height);
247 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05, 80f32, location.x);
248 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node05, 50f32, location.y);
249 let layout = taffy.layout(node06).unwrap();
250 let Layout { size, location, .. } = layout;
251 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06, 20f32, size.width);
252 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06, 40f32, size.height);
253 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06, 20f32, location.x);
254 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node06, 100f32, location.y);
255 let layout = taffy.layout(node07).unwrap();
256 let Layout { size, location, .. } = layout;
257 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07, 20f32, size.width);
258 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07, 40f32, size.height);
259 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07, 50f32, location.x);
260 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node07, 100f32, location.y);
261 let layout = taffy.layout(node08).unwrap();
262 let Layout { size, location, .. } = layout;
263 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08, 20f32, size.width);
264 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08, 40f32, size.height);
265 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08, 80f32, location.x);
266 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node08, 100f32, location.y);
267}