⎇ 25571b5d07206880207e451af69dd3b49b113628
tests/generated/flex/flex_wrap_align_stretch_fits_one_row.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn flex_wrap_align_stretch_fits_one_row__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size { width: taffy::style::Dimension::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::Length(50f32), height: auto() },
16 ..Default::default()
17 })
18 .unwrap();
19 let node = taffy
20 .new_with_children(
21 taffy::style::Style {
22 flex_wrap: taffy::style::FlexWrap::Wrap,
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::Length(150f32),
25 height: taffy::style::Dimension::Length(100f32),
26 },
27 ..Default::default()
28 },
29 &[node0, node1],
30 )
31 .unwrap();
32 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
33 println!("\nComputed tree:");
34 taffy.print_tree(node);
35 println!();
36 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
37 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
38 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
39 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
42 #[cfg(feature = "content_size")]
43 assert_eq!(
44 layout.scroll_width(),
45 0f32,
46 "scroll_width of node {:?}. Expected {}. Actual {}",
47 node,
48 0f32,
49 layout.scroll_width()
50 );
51 #[cfg(feature = "content_size")]
52 assert_eq!(
53 layout.scroll_height(),
54 0f32,
55 "scroll_height of node {:?}. Expected {}. Actual {}",
56 node,
57 0f32,
58 layout.scroll_height()
59 );
60 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
61 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
62 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
63 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
64 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
65 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
66 #[cfg(feature = "content_size")]
67 assert_eq!(
68 layout.scroll_width(),
69 0f32,
70 "scroll_width of node {:?}. Expected {}. Actual {}",
71 node0,
72 0f32,
73 layout.scroll_width()
74 );
75 #[cfg(feature = "content_size")]
76 assert_eq!(
77 layout.scroll_height(),
78 0f32,
79 "scroll_height of node {:?}. Expected {}. Actual {}",
80 node0,
81 0f32,
82 layout.scroll_height()
83 );
84 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
85 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
86 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
87 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
88 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
89 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
90 #[cfg(feature = "content_size")]
91 assert_eq!(
92 layout.scroll_width(),
93 0f32,
94 "scroll_width of node {:?}. Expected {}. Actual {}",
95 node1,
96 0f32,
97 layout.scroll_width()
98 );
99 #[cfg(feature = "content_size")]
100 assert_eq!(
101 layout.scroll_height(),
102 0f32,
103 "scroll_height of node {:?}. Expected {}. Actual {}",
104 node1,
105 0f32,
106 layout.scroll_height()
107 );
108}
109
110#[test]
111#[allow(non_snake_case)]
112fn flex_wrap_align_stretch_fits_one_row__content_box() {
113 #[allow(unused_imports)]
114 use taffy::{prelude::*, tree::Layout, TaffyTree};
115 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
116 let node0 = taffy
117 .new_leaf(taffy::style::Style {
118 box_sizing: taffy::style::BoxSizing::ContentBox,
119 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
120 ..Default::default()
121 })
122 .unwrap();
123 let node1 = taffy
124 .new_leaf(taffy::style::Style {
125 box_sizing: taffy::style::BoxSizing::ContentBox,
126 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
127 ..Default::default()
128 })
129 .unwrap();
130 let node = taffy
131 .new_with_children(
132 taffy::style::Style {
133 box_sizing: taffy::style::BoxSizing::ContentBox,
134 flex_wrap: taffy::style::FlexWrap::Wrap,
135 size: taffy::geometry::Size {
136 width: taffy::style::Dimension::Length(150f32),
137 height: taffy::style::Dimension::Length(100f32),
138 },
139 ..Default::default()
140 },
141 &[node0, node1],
142 )
143 .unwrap();
144 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
145 println!("\nComputed tree:");
146 taffy.print_tree(node);
147 println!();
148 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
149 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
150 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
151 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
152 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
153 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
154 #[cfg(feature = "content_size")]
155 assert_eq!(
156 layout.scroll_width(),
157 0f32,
158 "scroll_width of node {:?}. Expected {}. Actual {}",
159 node,
160 0f32,
161 layout.scroll_width()
162 );
163 #[cfg(feature = "content_size")]
164 assert_eq!(
165 layout.scroll_height(),
166 0f32,
167 "scroll_height of node {:?}. Expected {}. Actual {}",
168 node,
169 0f32,
170 layout.scroll_height()
171 );
172 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
173 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
174 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
175 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
176 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
177 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
178 #[cfg(feature = "content_size")]
179 assert_eq!(
180 layout.scroll_width(),
181 0f32,
182 "scroll_width of node {:?}. Expected {}. Actual {}",
183 node0,
184 0f32,
185 layout.scroll_width()
186 );
187 #[cfg(feature = "content_size")]
188 assert_eq!(
189 layout.scroll_height(),
190 0f32,
191 "scroll_height of node {:?}. Expected {}. Actual {}",
192 node0,
193 0f32,
194 layout.scroll_height()
195 );
196 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
197 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
198 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
199 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
200 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
201 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
202 #[cfg(feature = "content_size")]
203 assert_eq!(
204 layout.scroll_width(),
205 0f32,
206 "scroll_width of node {:?}. Expected {}. Actual {}",
207 node1,
208 0f32,
209 layout.scroll_width()
210 );
211 #[cfg(feature = "content_size")]
212 assert_eq!(
213 layout.scroll_height(),
214 0f32,
215 "scroll_height of node {:?}. Expected {}. Actual {}",
216 node1,
217 0f32,
218 layout.scroll_height()
219 );
220}