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