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