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