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