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