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