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