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