Rename FlexboxLayout back to Style (#251)
1#[test]
2fn rounding_total_fractial_nested() {
3 let mut taffy = taffy::Taffy::new();
4 let node00 = taffy
5 .new_with_children(
6 taffy::style::Style {
7 flex_grow: 1f32,
8 flex_basis: taffy::style::Dimension::Points(0.3f32),
9 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(9.9f32), ..Default::default() },
10 position: taffy::geometry::Rect {
11 bottom: taffy::style::Dimension::Points(13.3f32),
12 ..Default::default()
13 },
14 ..Default::default()
15 },
16 &[],
17 )
18 .unwrap();
19 let node01 = taffy
20 .new_with_children(
21 taffy::style::Style {
22 flex_grow: 4f32,
23 flex_basis: taffy::style::Dimension::Points(0.3f32),
24 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(1.1f32), ..Default::default() },
25 position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(13.3f32), ..Default::default() },
26 ..Default::default()
27 },
28 &[],
29 )
30 .unwrap();
31 let node0 = taffy
32 .new_with_children(
33 taffy::style::Style {
34 flex_direction: taffy::style::FlexDirection::Column,
35 flex_grow: 0.7f32,
36 flex_basis: taffy::style::Dimension::Points(50.3f32),
37 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(20.3f32), ..Default::default() },
38 ..Default::default()
39 },
40 &[node00, node01],
41 )
42 .unwrap();
43 let node1 = taffy
44 .new_with_children(
45 taffy::style::Style {
46 flex_grow: 1.6f32,
47 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() },
48 ..Default::default()
49 },
50 &[],
51 )
52 .unwrap();
53 let node2 = taffy
54 .new_with_children(
55 taffy::style::Style {
56 flex_grow: 1.1f32,
57 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10.7f32), ..Default::default() },
58 ..Default::default()
59 },
60 &[],
61 )
62 .unwrap();
63 let node = taffy
64 .new_with_children(
65 taffy::style::Style {
66 flex_direction: taffy::style::FlexDirection::Column,
67 size: taffy::geometry::Size {
68 width: taffy::style::Dimension::Points(87.4f32),
69 height: taffy::style::Dimension::Points(113.4f32),
70 ..Default::default()
71 },
72 ..Default::default()
73 },
74 &[node0, node1, node2],
75 )
76 .unwrap();
77 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
78 assert_eq!(taffy.layout(node).unwrap().size.width, 87f32);
79 assert_eq!(taffy.layout(node).unwrap().size.height, 113f32);
80 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
81 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
82 assert_eq!(taffy.layout(node0).unwrap().size.width, 87f32);
83 assert_eq!(taffy.layout(node0).unwrap().size.height, 59f32);
84 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
85 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
86 assert_eq!(taffy.layout(node00).unwrap().size.width, 87f32);
87 assert_eq!(taffy.layout(node00).unwrap().size.height, 12f32);
88 assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
89 assert_eq!(taffy.layout(node00).unwrap().location.y, -13f32);
90 assert_eq!(taffy.layout(node01).unwrap().size.width, 87f32);
91 assert_eq!(taffy.layout(node01).unwrap().size.height, 47f32);
92 assert_eq!(taffy.layout(node01).unwrap().location.x, 0f32);
93 assert_eq!(taffy.layout(node01).unwrap().location.y, 25f32);
94 assert_eq!(taffy.layout(node1).unwrap().size.width, 87f32);
95 assert_eq!(taffy.layout(node1).unwrap().size.height, 30f32);
96 assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
97 assert_eq!(taffy.layout(node1).unwrap().location.y, 59f32);
98 assert_eq!(taffy.layout(node2).unwrap().size.width, 87f32);
99 assert_eq!(taffy.layout(node2).unwrap().size.height, 24f32);
100 assert_eq!(taffy.layout(node2).unwrap().location.x, 0f32);
101 assert_eq!(taffy.layout(node2).unwrap().location.y, 89f32);
102}