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