⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/align_content_stretch_row.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn align_content_stretch_row() {
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(50f32), 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(50f32), 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(50f32), 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(50f32), 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(50f32), height: auto() },
33 ..Default::default()
34 })
35 .unwrap();
36 let node = taffy
37 .new_with_children(
38 taffy::style::Style {
39 flex_wrap: taffy::style::FlexWrap::Wrap,
40 align_content: Some(taffy::style::AlignContent::Stretch),
41 size: taffy::geometry::Size {
42 width: taffy::style::Dimension::Length(150f32),
43 height: taffy::style::Dimension::Length(100f32),
44 },
45 ..Default::default()
46 },
47 &[node0, node1, node2, node3, node4],
48 )
49 .unwrap();
50 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
51 println!("\nComputed tree:");
52 taffy.print_tree(node);
53 println!();
54 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
55 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
56 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
57 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
58 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
59 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
60 #[cfg(feature = "content_size")]
61 assert_eq!(
62 layout.scroll_width(),
63 0f32,
64 "scroll_width of node {:?}. Expected {}. Actual {}",
65 node,
66 0f32,
67 layout.scroll_width()
68 );
69 #[cfg(feature = "content_size")]
70 assert_eq!(
71 layout.scroll_height(),
72 0f32,
73 "scroll_height of node {:?}. Expected {}. Actual {}",
74 node,
75 0f32,
76 layout.scroll_height()
77 );
78 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
79 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
80 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
81 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
82 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
83 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
84 #[cfg(feature = "content_size")]
85 assert_eq!(
86 layout.scroll_width(),
87 0f32,
88 "scroll_width of node {:?}. Expected {}. Actual {}",
89 node0,
90 0f32,
91 layout.scroll_width()
92 );
93 #[cfg(feature = "content_size")]
94 assert_eq!(
95 layout.scroll_height(),
96 0f32,
97 "scroll_height of node {:?}. Expected {}. Actual {}",
98 node0,
99 0f32,
100 layout.scroll_height()
101 );
102 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
103 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
104 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
105 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node1, 50f32, size.height);
106 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
107 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
108 #[cfg(feature = "content_size")]
109 assert_eq!(
110 layout.scroll_width(),
111 0f32,
112 "scroll_width of node {:?}. Expected {}. Actual {}",
113 node1,
114 0f32,
115 layout.scroll_width()
116 );
117 #[cfg(feature = "content_size")]
118 assert_eq!(
119 layout.scroll_height(),
120 0f32,
121 "scroll_height of node {:?}. Expected {}. Actual {}",
122 node1,
123 0f32,
124 layout.scroll_height()
125 );
126 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
127 let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
128 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
129 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node2, 50f32, size.height);
130 assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2, 100f32, location.x);
131 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
132 #[cfg(feature = "content_size")]
133 assert_eq!(
134 layout.scroll_width(),
135 0f32,
136 "scroll_width of node {:?}. Expected {}. Actual {}",
137 node2,
138 0f32,
139 layout.scroll_width()
140 );
141 #[cfg(feature = "content_size")]
142 assert_eq!(
143 layout.scroll_height(),
144 0f32,
145 "scroll_height of node {:?}. Expected {}. Actual {}",
146 node2,
147 0f32,
148 layout.scroll_height()
149 );
150 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
151 let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
152 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
153 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node3, 50f32, size.height);
154 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
155 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node3, 50f32, location.y);
156 #[cfg(feature = "content_size")]
157 assert_eq!(
158 layout.scroll_width(),
159 0f32,
160 "scroll_width of node {:?}. Expected {}. Actual {}",
161 node3,
162 0f32,
163 layout.scroll_width()
164 );
165 #[cfg(feature = "content_size")]
166 assert_eq!(
167 layout.scroll_height(),
168 0f32,
169 "scroll_height of node {:?}. Expected {}. Actual {}",
170 node3,
171 0f32,
172 layout.scroll_height()
173 );
174 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
175 let layout @ Layout { size, location, .. } = taffy.layout(node4).unwrap();
176 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
177 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node4, 50f32, size.height);
178 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4, 50f32, location.x);
179 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node4, 50f32, location.y);
180 #[cfg(feature = "content_size")]
181 assert_eq!(
182 layout.scroll_width(),
183 0f32,
184 "scroll_width of node {:?}. Expected {}. Actual {}",
185 node4,
186 0f32,
187 layout.scroll_width()
188 );
189 #[cfg(feature = "content_size")]
190 assert_eq!(
191 layout.scroll_height(),
192 0f32,
193 "scroll_height of node {:?}. Expected {}. Actual {}",
194 node4,
195 0f32,
196 layout.scroll_height()
197 );
198}