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