⎇ float-layout
tests/generated/grid/grid_align_items_baseline_child_top2.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_top2__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 ..Default::default()
15 })
16 .unwrap();
17 let node10 = taffy
18 .new_leaf(taffy::style::Style {
19 display: taffy::style::Display::Grid,
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::from_length(50f32),
22 height: taffy::style::Dimension::from_length(10f32),
23 },
24 ..Default::default()
25 })
26 .unwrap();
27 let node1 = taffy
28 .new_with_children(
29 taffy::style::Style {
30 display: taffy::style::Display::Grid,
31 size: taffy::geometry::Size {
32 width: taffy::style::Dimension::from_length(50f32),
33 height: taffy::style::Dimension::from_length(20f32),
34 },
35 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(5f32), bottom: auto() },
36 ..Default::default()
37 },
38 &[node10],
39 )
40 .unwrap();
41 let node = taffy
42 .new_with_children(
43 taffy::style::Style {
44 display: taffy::style::Display::Grid,
45 align_items: Some(taffy::style::AlignItems::Baseline),
46 size: taffy::geometry::Size {
47 width: taffy::style::Dimension::from_length(100f32),
48 height: taffy::style::Dimension::from_length(100f32),
49 },
50 ..Default::default()
51 },
52 &[node0, node1],
53 )
54 .unwrap();
55 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
56 println!("\nComputed tree:");
57 taffy.print_tree(node);
58 println!();
59 let layout = taffy.layout(node).unwrap();
60 let Layout { size, location, .. } = layout;
61 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
62 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
63 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
64 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
65 let layout = taffy.layout(node0).unwrap();
66 let Layout { size, location, .. } = layout;
67 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
68 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
69 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
70 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
71 let layout = taffy.layout(node1).unwrap();
72 let Layout { size, location, .. } = layout;
73 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
74 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
75 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
76 assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y);
77 let layout = taffy.layout(node10).unwrap();
78 let Layout { size, location, .. } = layout;
79 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
80 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
81 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
82 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
83}
84
85#[test]
86#[allow(non_snake_case)]
87fn grid_align_items_baseline_child_top2__content_box() {
88 #[allow(unused_imports)]
89 use taffy::{prelude::*, Layout};
90 let mut taffy = crate::new_test_tree();
91 let node0 = taffy
92 .new_leaf(taffy::style::Style {
93 display: taffy::style::Display::Grid,
94 box_sizing: taffy::style::BoxSizing::ContentBox,
95 size: taffy::geometry::Size {
96 width: taffy::style::Dimension::from_length(50f32),
97 height: taffy::style::Dimension::from_length(50f32),
98 },
99 ..Default::default()
100 })
101 .unwrap();
102 let node10 = 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(10f32),
109 },
110 ..Default::default()
111 })
112 .unwrap();
113 let node1 = taffy
114 .new_with_children(
115 taffy::style::Style {
116 display: taffy::style::Display::Grid,
117 box_sizing: taffy::style::BoxSizing::ContentBox,
118 size: taffy::geometry::Size {
119 width: taffy::style::Dimension::from_length(50f32),
120 height: taffy::style::Dimension::from_length(20f32),
121 },
122 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(5f32), bottom: auto() },
123 ..Default::default()
124 },
125 &[node10],
126 )
127 .unwrap();
128 let node = taffy
129 .new_with_children(
130 taffy::style::Style {
131 display: taffy::style::Display::Grid,
132 box_sizing: taffy::style::BoxSizing::ContentBox,
133 align_items: Some(taffy::style::AlignItems::Baseline),
134 size: taffy::geometry::Size {
135 width: taffy::style::Dimension::from_length(100f32),
136 height: taffy::style::Dimension::from_length(100f32),
137 },
138 ..Default::default()
139 },
140 &[node0, node1],
141 )
142 .unwrap();
143 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
144 println!("\nComputed tree:");
145 taffy.print_tree(node);
146 println!();
147 let layout = taffy.layout(node).unwrap();
148 let Layout { size, location, .. } = layout;
149 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
150 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
151 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
152 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
153 let layout = taffy.layout(node0).unwrap();
154 let Layout { size, location, .. } = layout;
155 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
156 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
157 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
158 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
159 let layout = taffy.layout(node1).unwrap();
160 let Layout { size, location, .. } = layout;
161 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
162 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
163 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
164 assert_eq!(location.y, 70f32, "y of node {:?}. Expected {}. Actual {}", node1, 70f32, location.y);
165 let layout = taffy.layout(node10).unwrap();
166 let Layout { size, location, .. } = layout;
167 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
168 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
169 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
170 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
171}