⎇ float-layout
tests/generated/grid/grid_align_items_baseline_child_top.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_align_items_baseline_child_top__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 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() },
15 ..Default::default()
16 })
17 .unwrap();
18 let node10 = taffy
19 .new_leaf(taffy::style::Style {
20 display: taffy::style::Display::Grid,
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::from_length(50f32),
23 height: taffy::style::Dimension::from_length(10f32),
24 },
25 ..Default::default()
26 })
27 .unwrap();
28 let node1 = taffy
29 .new_with_children(
30 taffy::style::Style {
31 display: taffy::style::Display::Grid,
32 size: taffy::geometry::Size {
33 width: taffy::style::Dimension::from_length(50f32),
34 height: taffy::style::Dimension::from_length(20f32),
35 },
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, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, 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, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, 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_top__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 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() },
100 ..Default::default()
101 })
102 .unwrap();
103 let node10 = taffy
104 .new_leaf(taffy::style::Style {
105 display: taffy::style::Display::Grid,
106 box_sizing: taffy::style::BoxSizing::ContentBox,
107 size: taffy::geometry::Size {
108 width: taffy::style::Dimension::from_length(50f32),
109 height: taffy::style::Dimension::from_length(10f32),
110 },
111 ..Default::default()
112 })
113 .unwrap();
114 let node1 = taffy
115 .new_with_children(
116 taffy::style::Style {
117 display: taffy::style::Display::Grid,
118 box_sizing: taffy::style::BoxSizing::ContentBox,
119 size: taffy::geometry::Size {
120 width: taffy::style::Dimension::from_length(50f32),
121 height: taffy::style::Dimension::from_length(20f32),
122 },
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, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, 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, 65f32, "y of node {:?}. Expected {}. Actual {}", node1, 65f32, 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}