⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/align_baseline_nested_column.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_baseline_nested_column__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 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::from_length(50f32),
11 height: taffy::style::Dimension::from_length(60f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node100 = taffy
17 .new_leaf(taffy::style::Style {
18 flex_direction: taffy::style::FlexDirection::Column,
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(50f32),
21 height: taffy::style::Dimension::from_length(30f32),
22 },
23 ..Default::default()
24 })
25 .unwrap();
26 let node101 = taffy
27 .new_leaf(taffy::style::Style {
28 flex_direction: taffy::style::FlexDirection::Column,
29 size: taffy::geometry::Size {
30 width: taffy::style::Dimension::from_length(50f32),
31 height: taffy::style::Dimension::from_length(40f32),
32 },
33 ..Default::default()
34 })
35 .unwrap();
36 let node10 = taffy
37 .new_with_children(
38 taffy::style::Style {
39 flex_direction: taffy::style::FlexDirection::Column,
40 size: taffy::geometry::Size {
41 width: taffy::style::Dimension::from_length(50f32),
42 height: taffy::style::Dimension::from_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 { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
52 &[node10],
53 )
54 .unwrap();
55 let node = taffy
56 .new_with_children(
57 taffy::style::Style {
58 align_items: Some(taffy::style::AlignItems::Baseline),
59 size: taffy::geometry::Size {
60 width: taffy::style::Dimension::from_length(100f32),
61 height: taffy::style::Dimension::from_length(100f32),
62 },
63 ..Default::default()
64 },
65 &[node0, node1],
66 )
67 .unwrap();
68 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
69 println!("\nComputed tree:");
70 taffy.print_tree(node);
71 println!();
72 let layout = taffy.layout(node).unwrap();
73 let Layout { size, location, .. } = layout;
74 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
75 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
76 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
77 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
78 let layout = taffy.layout(node0).unwrap();
79 let Layout { size, location, .. } = layout;
80 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
81 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, 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 let layout = taffy.layout(node1).unwrap();
85 let Layout { size, location, .. } = layout;
86 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
87 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height);
88 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
89 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
90 let layout = taffy.layout(node10).unwrap();
91 let Layout { size, location, .. } = layout;
92 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
93 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height);
94 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
95 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
96 let layout = taffy.layout(node100).unwrap();
97 let Layout { size, location, .. } = layout;
98 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width);
99 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height);
100 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x);
101 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y);
102 let layout = taffy.layout(node101).unwrap();
103 let Layout { size, location, .. } = layout;
104 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width);
105 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height);
106 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x);
107 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node101, 30f32, location.y);
108}
109
110#[test]
111#[allow(non_snake_case)]
112fn align_baseline_nested_column__content_box() {
113 #[allow(unused_imports)]
114 use taffy::{prelude::*, Layout};
115 let mut taffy = crate::new_test_tree();
116 let node0 = taffy
117 .new_leaf(taffy::style::Style {
118 box_sizing: taffy::style::BoxSizing::ContentBox,
119 size: taffy::geometry::Size {
120 width: taffy::style::Dimension::from_length(50f32),
121 height: taffy::style::Dimension::from_length(60f32),
122 },
123 ..Default::default()
124 })
125 .unwrap();
126 let node100 = taffy
127 .new_leaf(taffy::style::Style {
128 box_sizing: taffy::style::BoxSizing::ContentBox,
129 flex_direction: taffy::style::FlexDirection::Column,
130 size: taffy::geometry::Size {
131 width: taffy::style::Dimension::from_length(50f32),
132 height: taffy::style::Dimension::from_length(30f32),
133 },
134 ..Default::default()
135 })
136 .unwrap();
137 let node101 = taffy
138 .new_leaf(taffy::style::Style {
139 box_sizing: taffy::style::BoxSizing::ContentBox,
140 flex_direction: taffy::style::FlexDirection::Column,
141 size: taffy::geometry::Size {
142 width: taffy::style::Dimension::from_length(50f32),
143 height: taffy::style::Dimension::from_length(40f32),
144 },
145 ..Default::default()
146 })
147 .unwrap();
148 let node10 = taffy
149 .new_with_children(
150 taffy::style::Style {
151 box_sizing: taffy::style::BoxSizing::ContentBox,
152 flex_direction: taffy::style::FlexDirection::Column,
153 size: taffy::geometry::Size {
154 width: taffy::style::Dimension::from_length(50f32),
155 height: taffy::style::Dimension::from_length(80f32),
156 },
157 ..Default::default()
158 },
159 &[node100, node101],
160 )
161 .unwrap();
162 let node1 = taffy
163 .new_with_children(
164 taffy::style::Style {
165 box_sizing: taffy::style::BoxSizing::ContentBox,
166 flex_direction: taffy::style::FlexDirection::Column,
167 ..Default::default()
168 },
169 &[node10],
170 )
171 .unwrap();
172 let node = taffy
173 .new_with_children(
174 taffy::style::Style {
175 box_sizing: taffy::style::BoxSizing::ContentBox,
176 align_items: Some(taffy::style::AlignItems::Baseline),
177 size: taffy::geometry::Size {
178 width: taffy::style::Dimension::from_length(100f32),
179 height: taffy::style::Dimension::from_length(100f32),
180 },
181 ..Default::default()
182 },
183 &[node0, node1],
184 )
185 .unwrap();
186 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
187 println!("\nComputed tree:");
188 taffy.print_tree(node);
189 println!();
190 let layout = taffy.layout(node).unwrap();
191 let Layout { size, location, .. } = layout;
192 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
193 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
194 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
195 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
196 let layout = taffy.layout(node0).unwrap();
197 let Layout { size, location, .. } = layout;
198 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
199 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, size.height);
200 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
201 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
202 let layout = taffy.layout(node1).unwrap();
203 let Layout { size, location, .. } = layout;
204 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
205 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node1, 80f32, size.height);
206 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
207 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
208 let layout = taffy.layout(node10).unwrap();
209 let Layout { size, location, .. } = layout;
210 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
211 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node10, 80f32, size.height);
212 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
213 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
214 let layout = taffy.layout(node100).unwrap();
215 let Layout { size, location, .. } = layout;
216 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node100, 50f32, size.width);
217 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node100, 30f32, size.height);
218 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node100, 0f32, location.x);
219 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node100, 0f32, location.y);
220 let layout = taffy.layout(node101).unwrap();
221 let Layout { size, location, .. } = layout;
222 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node101, 50f32, size.width);
223 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node101, 40f32, size.height);
224 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node101, 0f32, location.x);
225 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node101, 30f32, location.y);
226}