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