⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/block/block_align_baseline_child_top.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn block_align_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::Block,
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::Block,
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::Block,
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 align_items: Some(taffy::style::AlignItems::Baseline),
45 size: taffy::geometry::Size {
46 width: taffy::style::Dimension::from_length(100f32),
47 height: taffy::style::Dimension::from_length(100f32),
48 },
49 ..Default::default()
50 },
51 &[node0, node1],
52 )
53 .unwrap();
54 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
55 println!("\nComputed tree:");
56 taffy.print_tree(node);
57 println!();
58 let layout = taffy.layout(node).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
61 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
62 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
64 let layout = taffy.layout(node0).unwrap();
65 let Layout { size, location, .. } = layout;
66 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
67 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
69 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
70 let layout = taffy.layout(node1).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
73 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
74 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
75 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
76 let layout = taffy.layout(node10).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
79 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
80 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
82}
83
84#[test]
85#[allow(non_snake_case)]
86fn block_align_baseline_child_top__content_box() {
87 #[allow(unused_imports)]
88 use taffy::{prelude::*, Layout};
89 let mut taffy = crate::new_test_tree();
90 let node0 = taffy
91 .new_leaf(taffy::style::Style {
92 display: taffy::style::Display::Block,
93 box_sizing: taffy::style::BoxSizing::ContentBox,
94 size: taffy::geometry::Size {
95 width: taffy::style::Dimension::from_length(50f32),
96 height: taffy::style::Dimension::from_length(50f32),
97 },
98 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: length(10f32), bottom: auto() },
99 ..Default::default()
100 })
101 .unwrap();
102 let node10 = taffy
103 .new_leaf(taffy::style::Style {
104 display: taffy::style::Display::Block,
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::Block,
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 ..Default::default()
123 },
124 &[node10],
125 )
126 .unwrap();
127 let node = taffy
128 .new_with_children(
129 taffy::style::Style {
130 box_sizing: taffy::style::BoxSizing::ContentBox,
131 align_items: Some(taffy::style::AlignItems::Baseline),
132 size: taffy::geometry::Size {
133 width: taffy::style::Dimension::from_length(100f32),
134 height: taffy::style::Dimension::from_length(100f32),
135 },
136 ..Default::default()
137 },
138 &[node0, node1],
139 )
140 .unwrap();
141 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
142 println!("\nComputed tree:");
143 taffy.print_tree(node);
144 println!();
145 let layout = taffy.layout(node).unwrap();
146 let Layout { size, location, .. } = layout;
147 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
148 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
149 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
150 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
151 let layout = taffy.layout(node0).unwrap();
152 let Layout { size, location, .. } = layout;
153 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
154 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
155 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
156 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
157 let layout = taffy.layout(node1).unwrap();
158 let Layout { size, location, .. } = layout;
159 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
160 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
161 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
162 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
163 let layout = taffy.layout(node10).unwrap();
164 let Layout { size, location, .. } = layout;
165 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
166 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
167 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
168 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
169}