⎇ direction-floats
tests/generated/flex/wrap_row_align_items_flex_end.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn wrap_row_align_items_flex_end__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(10f32),
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(20f32),
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(30f32),
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(30f32),
39 },
40 ..Default::default()
41 })
42 .unwrap();
43 let node = taffy
44 .new_with_children(
45 taffy::style::Style {
46 flex_wrap: taffy::style::FlexWrap::Wrap,
47 align_items: Some(taffy::style::AlignItems::FlexEnd),
48 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
49 ..Default::default()
50 },
51 &[node0, node1, node2, node3],
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, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, 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, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
67 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
69 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y);
70 let layout = taffy.layout(node1).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
73 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
74 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
75 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
76 let layout = taffy.layout(node2).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width);
79 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height);
80 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
82 let layout = taffy.layout(node3).unwrap();
83 let Layout { size, location, .. } = layout;
84 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width);
85 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
87 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y);
88}
89
90#[test]
91#[allow(non_snake_case)]
92fn wrap_row_align_items_flex_end__content_box() {
93 #[allow(unused_imports)]
94 use taffy::{prelude::*, Layout};
95 let mut taffy = crate::new_test_tree();
96 let node0 = taffy
97 .new_leaf(taffy::style::Style {
98 box_sizing: taffy::style::BoxSizing::ContentBox,
99 size: taffy::geometry::Size {
100 width: taffy::style::Dimension::from_length(30f32),
101 height: taffy::style::Dimension::from_length(10f32),
102 },
103 ..Default::default()
104 })
105 .unwrap();
106 let node1 = taffy
107 .new_leaf(taffy::style::Style {
108 box_sizing: taffy::style::BoxSizing::ContentBox,
109 size: taffy::geometry::Size {
110 width: taffy::style::Dimension::from_length(30f32),
111 height: taffy::style::Dimension::from_length(20f32),
112 },
113 ..Default::default()
114 })
115 .unwrap();
116 let node2 = taffy
117 .new_leaf(taffy::style::Style {
118 box_sizing: taffy::style::BoxSizing::ContentBox,
119 size: taffy::geometry::Size {
120 width: taffy::style::Dimension::from_length(30f32),
121 height: taffy::style::Dimension::from_length(30f32),
122 },
123 ..Default::default()
124 })
125 .unwrap();
126 let node3 = taffy
127 .new_leaf(taffy::style::Style {
128 box_sizing: taffy::style::BoxSizing::ContentBox,
129 size: taffy::geometry::Size {
130 width: taffy::style::Dimension::from_length(30f32),
131 height: taffy::style::Dimension::from_length(30f32),
132 },
133 ..Default::default()
134 })
135 .unwrap();
136 let node = taffy
137 .new_with_children(
138 taffy::style::Style {
139 box_sizing: taffy::style::BoxSizing::ContentBox,
140 flex_wrap: taffy::style::FlexWrap::Wrap,
141 align_items: Some(taffy::style::AlignItems::FlexEnd),
142 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
143 ..Default::default()
144 },
145 &[node0, node1, node2, node3],
146 )
147 .unwrap();
148 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
149 println!("\nComputed tree:");
150 taffy.print_tree(node);
151 println!();
152 let layout = taffy.layout(node).unwrap();
153 let Layout { size, location, .. } = layout;
154 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
155 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node, 60f32, size.height);
156 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
157 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
158 let layout = taffy.layout(node0).unwrap();
159 let Layout { size, location, .. } = layout;
160 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
161 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
162 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
163 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node0, 20f32, location.y);
164 let layout = taffy.layout(node1).unwrap();
165 let Layout { size, location, .. } = layout;
166 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
167 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
168 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
169 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
170 let layout = taffy.layout(node2).unwrap();
171 let Layout { size, location, .. } = layout;
172 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width);
173 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node2, 30f32, size.height);
174 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
175 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
176 let layout = taffy.layout(node3).unwrap();
177 let Layout { size, location, .. } = layout;
178 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width);
179 assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node3, 30f32, size.height);
180 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
181 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node3, 30f32, location.y);
182}