⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_align_items_baseline_child_margin_percent.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_align_items_baseline_child_margin_percent__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 display: taffy::style::Display::Grid,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(50f32),
12 height: taffy::style::Dimension::from_length(50f32),
13 },
14 margin: taffy::geometry::Rect {
15 left: percent(0.05f32),
16 right: percent(0.05f32),
17 top: percent(0.05f32),
18 bottom: percent(0.05f32),
19 },
20 ..Default::default()
21 })
22 .unwrap();
23 let node10 = taffy
24 .new_leaf(taffy::style::Style {
25 display: taffy::style::Display::Grid,
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::from_length(50f32),
28 height: taffy::style::Dimension::from_length(10f32),
29 },
30 margin: taffy::geometry::Rect {
31 left: percent(0.01f32),
32 right: percent(0.01f32),
33 top: percent(0.01f32),
34 bottom: percent(0.01f32),
35 },
36 ..Default::default()
37 })
38 .unwrap();
39 let node1 = taffy
40 .new_with_children(
41 taffy::style::Style {
42 display: taffy::style::Display::Grid,
43 size: taffy::geometry::Size {
44 width: taffy::style::Dimension::from_length(50f32),
45 height: taffy::style::Dimension::from_length(20f32),
46 },
47 ..Default::default()
48 },
49 &[node10],
50 )
51 .unwrap();
52 let node = taffy
53 .new_with_children(
54 taffy::style::Style {
55 display: taffy::style::Display::Grid,
56 align_items: Some(taffy::style::AlignItems::Baseline),
57 size: taffy::geometry::Size {
58 width: taffy::style::Dimension::from_length(100f32),
59 height: taffy::style::Dimension::from_length(100f32),
60 },
61 ..Default::default()
62 },
63 &[node0, node1],
64 )
65 .unwrap();
66 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
67 println!("\nComputed tree:");
68 taffy.print_tree(node);
69 println!();
70 let layout = taffy.layout(node).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
73 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
76 let layout = taffy.layout(node0).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
79 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
80 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x);
81 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y);
82 let layout = taffy.layout(node1).unwrap();
83 let Layout { size, location, .. } = layout;
84 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
85 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
87 assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y);
88 let layout = taffy.layout(node10).unwrap();
89 let Layout { size, location, .. } = layout;
90 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
91 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
92 assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x);
93 assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y);
94}
95
96#[test]
97#[allow(non_snake_case)]
98fn grid_align_items_baseline_child_margin_percent__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 display: taffy::style::Display::Grid,
105 box_sizing: taffy::style::BoxSizing::ContentBox,
106 size: taffy::geometry::Size {
107 width: taffy::style::Dimension::from_length(50f32),
108 height: taffy::style::Dimension::from_length(50f32),
109 },
110 margin: taffy::geometry::Rect {
111 left: percent(0.05f32),
112 right: percent(0.05f32),
113 top: percent(0.05f32),
114 bottom: percent(0.05f32),
115 },
116 ..Default::default()
117 })
118 .unwrap();
119 let node10 = taffy
120 .new_leaf(taffy::style::Style {
121 display: taffy::style::Display::Grid,
122 box_sizing: taffy::style::BoxSizing::ContentBox,
123 size: taffy::geometry::Size {
124 width: taffy::style::Dimension::from_length(50f32),
125 height: taffy::style::Dimension::from_length(10f32),
126 },
127 margin: taffy::geometry::Rect {
128 left: percent(0.01f32),
129 right: percent(0.01f32),
130 top: percent(0.01f32),
131 bottom: percent(0.01f32),
132 },
133 ..Default::default()
134 })
135 .unwrap();
136 let node1 = taffy
137 .new_with_children(
138 taffy::style::Style {
139 display: taffy::style::Display::Grid,
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 display: taffy::style::Display::Grid,
154 box_sizing: taffy::style::BoxSizing::ContentBox,
155 align_items: Some(taffy::style::AlignItems::Baseline),
156 size: taffy::geometry::Size {
157 width: taffy::style::Dimension::from_length(100f32),
158 height: taffy::style::Dimension::from_length(100f32),
159 },
160 ..Default::default()
161 },
162 &[node0, node1],
163 )
164 .unwrap();
165 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
166 println!("\nComputed tree:");
167 taffy.print_tree(node);
168 println!();
169 let layout = taffy.layout(node).unwrap();
170 let Layout { size, location, .. } = layout;
171 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
172 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
173 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
174 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
175 let layout = taffy.layout(node0).unwrap();
176 let Layout { size, location, .. } = layout;
177 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
178 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
179 assert_eq!(location.x, 5f32, "x of node {:?}. Expected {}. Actual {}", node0, 5f32, location.x);
180 assert_eq!(location.y, 5f32, "y of node {:?}. Expected {}. Actual {}", node0, 5f32, location.y);
181 let layout = taffy.layout(node1).unwrap();
182 let Layout { size, location, .. } = layout;
183 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
184 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
185 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
186 assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y);
187 let layout = taffy.layout(node10).unwrap();
188 let Layout { size, location, .. } = layout;
189 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
190 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
191 assert_eq!(location.x, 1f32, "x of node {:?}. Expected {}. Actual {}", node10, 1f32, location.x);
192 assert_eq!(location.y, 1f32, "y of node {:?}. Expected {}. Actual {}", node10, 1f32, location.y);
193}