1#[test]
2fn margin_auto_bottom_and_top() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_node(
6 taffy::style::Style {
7 size: taffy::geometry::Size {
8 width: taffy::style::Dimension::Points(50f32),
9 height: taffy::style::Dimension::Points(50f32),
10 ..Default::default()
11 },
12 margin: taffy::geometry::Rect {
13 top: taffy::style::Dimension::Auto,
14 bottom: taffy::style::Dimension::Auto,
15 ..Default::default()
16 },
17 ..Default::default()
18 },
19 &[],
20 )
21 .unwrap();
22 let node1 = taffy
23 .new_node(
24 taffy::style::Style {
25 size: taffy::geometry::Size {
26 width: taffy::style::Dimension::Points(50f32),
27 height: taffy::style::Dimension::Points(50f32),
28 ..Default::default()
29 },
30 ..Default::default()
31 },
32 &[],
33 )
34 .unwrap();
35 let node = taffy
36 .new_node(
37 taffy::style::Style {
38 align_items: taffy::style::AlignItems::Center,
39 size: taffy::geometry::Size {
40 width: taffy::style::Dimension::Points(200f32),
41 height: taffy::style::Dimension::Points(200f32),
42 ..Default::default()
43 },
44 ..Default::default()
45 },
46 &[node0, node1],
47 )
48 .unwrap();
49 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
50 assert_eq!(taffy.layout(node).unwrap().size.width, 200f32);
51 assert_eq!(taffy.layout(node).unwrap().size.height, 200f32);
52 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
53 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
54 assert_eq!(taffy.layout(node0).unwrap().size.width, 50f32);
55 assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32);
56 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
57 assert_eq!(taffy.layout(node0).unwrap().location.y, 75f32);
58 assert_eq!(taffy.layout(node1).unwrap().size.width, 50f32);
59 assert_eq!(taffy.layout(node1).unwrap().size.height, 50f32);
60 assert_eq!(taffy.layout(node1).unwrap().location.x, 50f32);
61 assert_eq!(taffy.layout(node1).unwrap().location.y, 75f32);
62}