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