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