⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/gap_row_gap_align_items_stretch.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn gap_row_gap_align_items_stretch() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
9 ..Default::default()
10 })
11 .unwrap();
12 let node1 = taffy
13 .new_leaf(taffy::style::Style {
14 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
15 ..Default::default()
16 })
17 .unwrap();
18 let node2 = taffy
19 .new_leaf(taffy::style::Style {
20 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
21 ..Default::default()
22 })
23 .unwrap();
24 let node3 = taffy
25 .new_leaf(taffy::style::Style {
26 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
27 ..Default::default()
28 })
29 .unwrap();
30 let node4 = taffy
31 .new_leaf(taffy::style::Style {
32 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
33 ..Default::default()
34 })
35 .unwrap();
36 let node5 = taffy
37 .new_leaf(taffy::style::Style {
38 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), 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_items: Some(taffy::style::AlignItems::Stretch),
47 align_content: Some(taffy::style::AlignContent::Stretch),
48 gap: taffy::geometry::Size {
49 width: taffy::style::LengthPercentage::Length(10f32),
50 height: taffy::style::LengthPercentage::Length(20f32),
51 },
52 size: taffy::geometry::Size {
53 width: taffy::style::Dimension::Length(100f32),
54 height: taffy::style::Dimension::Length(200f32),
55 },
56 ..Default::default()
57 },
58 &[node0, node1, node2, node3, node4, node5],
59 )
60 .unwrap();
61 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
62 println!("\nComputed tree:");
63 taffy.print_tree(node);
64 println!();
65 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
66 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
67 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
68 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
69 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
70 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
71 #[cfg(feature = "content_size")]
72 assert_eq!(
73 layout.scroll_width(),
74 0f32,
75 "scroll_width of node {:?}. Expected {}. Actual {}",
76 node,
77 0f32,
78 layout.scroll_width()
79 );
80 #[cfg(feature = "content_size")]
81 assert_eq!(
82 layout.scroll_height(),
83 0f32,
84 "scroll_height of node {:?}. Expected {}. Actual {}",
85 node,
86 0f32,
87 layout.scroll_height()
88 );
89 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
90 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
91 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
92 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node0, 90f32, size.height);
93 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
94 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
95 #[cfg(feature = "content_size")]
96 assert_eq!(
97 layout.scroll_width(),
98 0f32,
99 "scroll_width of node {:?}. Expected {}. Actual {}",
100 node0,
101 0f32,
102 layout.scroll_width()
103 );
104 #[cfg(feature = "content_size")]
105 assert_eq!(
106 layout.scroll_height(),
107 0f32,
108 "scroll_height of node {:?}. Expected {}. Actual {}",
109 node0,
110 0f32,
111 layout.scroll_height()
112 );
113 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
114 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
115 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
116 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node1, 90f32, size.height);
117 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
118 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
119 #[cfg(feature = "content_size")]
120 assert_eq!(
121 layout.scroll_width(),
122 0f32,
123 "scroll_width of node {:?}. Expected {}. Actual {}",
124 node1,
125 0f32,
126 layout.scroll_width()
127 );
128 #[cfg(feature = "content_size")]
129 assert_eq!(
130 layout.scroll_height(),
131 0f32,
132 "scroll_height of node {:?}. Expected {}. Actual {}",
133 node1,
134 0f32,
135 layout.scroll_height()
136 );
137 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
138 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
139 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
140 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node2, 90f32, size.height);
141 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
142 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
143 #[cfg(feature = "content_size")]
144 assert_eq!(
145 layout.scroll_width(),
146 0f32,
147 "scroll_width of node {:?}. Expected {}. Actual {}",
148 node2,
149 0f32,
150 layout.scroll_width()
151 );
152 #[cfg(feature = "content_size")]
153 assert_eq!(
154 layout.scroll_height(),
155 0f32,
156 "scroll_height of node {:?}. Expected {}. Actual {}",
157 node2,
158 0f32,
159 layout.scroll_height()
160 );
161 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
162 let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
163 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
164 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node3, 90f32, size.height);
165 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
166 assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node3, 110f32, location.y);
167 #[cfg(feature = "content_size")]
168 assert_eq!(
169 layout.scroll_width(),
170 0f32,
171 "scroll_width of node {:?}. Expected {}. Actual {}",
172 node3,
173 0f32,
174 layout.scroll_width()
175 );
176 #[cfg(feature = "content_size")]
177 assert_eq!(
178 layout.scroll_height(),
179 0f32,
180 "scroll_height of node {:?}. Expected {}. Actual {}",
181 node3,
182 0f32,
183 layout.scroll_height()
184 );
185 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
186 let layout @ Layout { size, location, .. } = taffy.layout(node4).unwrap();
187 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
188 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node4, 90f32, size.height);
189 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
190 assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node4, 110f32, location.y);
191 #[cfg(feature = "content_size")]
192 assert_eq!(
193 layout.scroll_width(),
194 0f32,
195 "scroll_width of node {:?}. Expected {}. Actual {}",
196 node4,
197 0f32,
198 layout.scroll_width()
199 );
200 #[cfg(feature = "content_size")]
201 assert_eq!(
202 layout.scroll_height(),
203 0f32,
204 "scroll_height of node {:?}. Expected {}. Actual {}",
205 node4,
206 0f32,
207 layout.scroll_height()
208 );
209 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
210 let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap();
211 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
212 assert_eq!(size.height, 90f32, "height of node {:?}. Expected {}. Actual {}", node5, 90f32, size.height);
213 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
214 assert_eq!(location.y, 110f32, "y of node {:?}. Expected {}. Actual {}", node5, 110f32, location.y);
215 #[cfg(feature = "content_size")]
216 assert_eq!(
217 layout.scroll_width(),
218 0f32,
219 "scroll_width of node {:?}. Expected {}. Actual {}",
220 node5,
221 0f32,
222 layout.scroll_width()
223 );
224 #[cfg(feature = "content_size")]
225 assert_eq!(
226 layout.scroll_height(),
227 0f32,
228 "scroll_height of node {:?}. Expected {}. Actual {}",
229 node5,
230 0f32,
231 layout.scroll_height()
232 );
233}