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