⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_absolute_container_top_right_margin.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_absolute_container_top_right_margin__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 position: taffy::style::Position::Absolute,
10 margin: taffy::geometry::Rect {
11 left: length(4f32),
12 right: length(2f32),
13 top: length(1f32),
14 bottom: length(3f32),
15 },
16 inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() },
17 ..Default::default()
18 })
19 .unwrap();
20 let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
21 let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
22 let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
23 let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
24 let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
25 let node6 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
26 let node7 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
27 let node8 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
28 let node = taffy
29 .new_with_children(
30 taffy::style::Style {
31 display: taffy::style::Display::Grid,
32 grid_template_rows: vec![length(40f32), length(40f32), length(40f32)],
33 grid_template_columns: vec![length(40f32), length(40f32), length(40f32)],
34 padding: taffy::geometry::Rect {
35 left: length(40f32),
36 right: length(20f32),
37 top: length(10f32),
38 bottom: length(30f32),
39 },
40 ..Default::default()
41 },
42 &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
43 )
44 .unwrap();
45 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
46 println!("\nComputed tree:");
47 taffy.print_tree(node);
48 println!();
49 let layout = taffy.layout(node).unwrap();
50 let Layout { size, location, .. } = layout;
51 assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width);
52 assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height);
53 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
55 let layout = taffy.layout(node0).unwrap();
56 let Layout { size, location, .. } = layout;
57 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
58 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
59 assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x);
60 assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y);
61 let layout = taffy.layout(node1).unwrap();
62 let Layout { size, location, .. } = layout;
63 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
64 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
65 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x);
66 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
67 let layout = taffy.layout(node2).unwrap();
68 let Layout { size, location, .. } = layout;
69 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
70 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
71 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x);
72 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y);
73 let layout = taffy.layout(node3).unwrap();
74 let Layout { size, location, .. } = layout;
75 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width);
76 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height);
77 assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x);
78 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y);
79 let layout = taffy.layout(node4).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width);
82 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height);
83 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x);
84 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y);
85 let layout = taffy.layout(node5).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width);
88 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height);
89 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x);
90 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y);
91 let layout = taffy.layout(node6).unwrap();
92 let Layout { size, location, .. } = layout;
93 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width);
94 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height);
95 assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x);
96 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y);
97 let layout = taffy.layout(node7).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width);
100 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height);
101 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x);
102 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y);
103 let layout = taffy.layout(node8).unwrap();
104 let Layout { size, location, .. } = layout;
105 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width);
106 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height);
107 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x);
108 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y);
109}
110
111#[test]
112#[allow(non_snake_case)]
113fn grid_absolute_container_top_right_margin__content_box() {
114 #[allow(unused_imports)]
115 use taffy::{prelude::*, Layout};
116 let mut taffy = crate::new_test_tree();
117 let node0 = taffy
118 .new_leaf(taffy::style::Style {
119 box_sizing: taffy::style::BoxSizing::ContentBox,
120 position: taffy::style::Position::Absolute,
121 margin: taffy::geometry::Rect {
122 left: length(4f32),
123 right: length(2f32),
124 top: length(1f32),
125 bottom: length(3f32),
126 },
127 inset: taffy::geometry::Rect { left: auto(), right: length(0f32), top: length(0f32), bottom: auto() },
128 ..Default::default()
129 })
130 .unwrap();
131 let node1 = taffy
132 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
133 .unwrap();
134 let node2 = taffy
135 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
136 .unwrap();
137 let node3 = taffy
138 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
139 .unwrap();
140 let node4 = taffy
141 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
142 .unwrap();
143 let node5 = taffy
144 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
145 .unwrap();
146 let node6 = taffy
147 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
148 .unwrap();
149 let node7 = taffy
150 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
151 .unwrap();
152 let node8 = taffy
153 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
154 .unwrap();
155 let node = taffy
156 .new_with_children(
157 taffy::style::Style {
158 display: taffy::style::Display::Grid,
159 box_sizing: taffy::style::BoxSizing::ContentBox,
160 grid_template_rows: vec![length(40f32), length(40f32), length(40f32)],
161 grid_template_columns: vec![length(40f32), length(40f32), length(40f32)],
162 padding: taffy::geometry::Rect {
163 left: length(40f32),
164 right: length(20f32),
165 top: length(10f32),
166 bottom: length(30f32),
167 },
168 ..Default::default()
169 },
170 &[node0, node1, node2, node3, node4, node5, node6, node7, node8],
171 )
172 .unwrap();
173 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
174 println!("\nComputed tree:");
175 taffy.print_tree(node);
176 println!();
177 let layout = taffy.layout(node).unwrap();
178 let Layout { size, location, .. } = layout;
179 assert_eq!(size.width, 180f32, "width of node {:?}. Expected {}. Actual {}", node, 180f32, size.width);
180 assert_eq!(size.height, 160f32, "height of node {:?}. Expected {}. Actual {}", node, 160f32, size.height);
181 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
182 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
183 let layout = taffy.layout(node0).unwrap();
184 let Layout { size, location, .. } = layout;
185 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
186 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
187 assert_eq!(location.x, 178f32, "x of node {:?}. Expected {}. Actual {}", node0, 178f32, location.x);
188 assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node0, 1f32, location.y);
189 let layout = taffy.layout(node1).unwrap();
190 let Layout { size, location, .. } = layout;
191 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
192 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
193 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x);
194 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
195 let layout = taffy.layout(node2).unwrap();
196 let Layout { size, location, .. } = layout;
197 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
198 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
199 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node2, 80f32, location.x);
200 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node2, 10f32, location.y);
201 let layout = taffy.layout(node3).unwrap();
202 let Layout { size, location, .. } = layout;
203 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node3, 40f32, size.width);
204 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node3, 40f32, size.height);
205 assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node3, 120f32, location.x);
206 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node3, 10f32, location.y);
207 let layout = taffy.layout(node4).unwrap();
208 let Layout { size, location, .. } = layout;
209 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node4, 40f32, size.width);
210 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node4, 40f32, size.height);
211 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4, 40f32, location.x);
212 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y);
213 let layout = taffy.layout(node5).unwrap();
214 let Layout { size, location, .. } = layout;
215 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node5, 40f32, size.width);
216 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node5, 40f32, size.height);
217 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node5, 80f32, location.x);
218 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node5, 50f32, location.y);
219 let layout = taffy.layout(node6).unwrap();
220 let Layout { size, location, .. } = layout;
221 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node6, 40f32, size.width);
222 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node6, 40f32, size.height);
223 assert_eq!(location.x, 120f32, "x of node {:?}. Expected {}. Actual {}", node6, 120f32, location.x);
224 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node6, 50f32, location.y);
225 let layout = taffy.layout(node7).unwrap();
226 let Layout { size, location, .. } = layout;
227 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node7, 40f32, size.width);
228 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node7, 40f32, size.height);
229 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node7, 40f32, location.x);
230 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node7, 90f32, location.y);
231 let layout = taffy.layout(node8).unwrap();
232 let Layout { size, location, .. } = layout;
233 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node8, 40f32, size.width);
234 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node8, 40f32, size.height);
235 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node8, 80f32, location.x);
236 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node8, 90f32, location.y);
237}