Rename FlexboxLayout back to Style (#251)
1#[test]
2fn absolute_layout_child_order() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_with_children(
6 taffy::style::Style {
7 size: taffy::geometry::Size {
8 width: taffy::style::Dimension::Points(60f32),
9 height: taffy::style::Dimension::Points(40f32),
10 ..Default::default()
11 },
12 ..Default::default()
13 },
14 &[],
15 )
16 .unwrap();
17 let node1 = taffy
18 .new_with_children(
19 taffy::style::Style {
20 position_type: taffy::style::PositionType::Absolute,
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::Points(60f32),
23 height: taffy::style::Dimension::Points(40f32),
24 ..Default::default()
25 },
26 ..Default::default()
27 },
28 &[],
29 )
30 .unwrap();
31 let node2 = taffy
32 .new_with_children(
33 taffy::style::Style {
34 size: taffy::geometry::Size {
35 width: taffy::style::Dimension::Points(60f32),
36 height: taffy::style::Dimension::Points(40f32),
37 ..Default::default()
38 },
39 ..Default::default()
40 },
41 &[],
42 )
43 .unwrap();
44 let node = taffy
45 .new_with_children(
46 taffy::style::Style {
47 align_items: taffy::style::AlignItems::Center,
48 justify_content: taffy::style::JustifyContent::Center,
49 size: taffy::geometry::Size {
50 width: taffy::style::Dimension::Points(110f32),
51 height: taffy::style::Dimension::Points(100f32),
52 ..Default::default()
53 },
54 ..Default::default()
55 },
56 &[node0, node1, node2],
57 )
58 .unwrap();
59 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
60 assert_eq!(taffy.layout(node).unwrap().size.width, 110f32);
61 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
62 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
63 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
64 assert_eq!(taffy.layout(node0).unwrap().size.width, 55f32);
65 assert_eq!(taffy.layout(node0).unwrap().size.height, 40f32);
66 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
67 assert_eq!(taffy.layout(node0).unwrap().location.y, 30f32);
68 assert_eq!(taffy.layout(node1).unwrap().size.width, 60f32);
69 assert_eq!(taffy.layout(node1).unwrap().size.height, 40f32);
70 assert_eq!(taffy.layout(node1).unwrap().location.x, 25f32);
71 assert_eq!(taffy.layout(node1).unwrap().location.y, 30f32);
72 assert_eq!(taffy.layout(node2).unwrap().size.width, 55f32);
73 assert_eq!(taffy.layout(node2).unwrap().size.height, 40f32);
74 assert_eq!(taffy.layout(node2).unwrap().location.x, 55f32);
75 assert_eq!(taffy.layout(node2).unwrap().location.y, 30f32);
76}