Rename Rect field start->left end->right (#257)
1#[test]
2fn percent_absolute_position() {
3 let mut taffy = taffy::Taffy::new();
4 let node00 = taffy
5 .new_with_children(
6 taffy::style::Style {
7 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() },
8 ..Default::default()
9 },
10 &[],
11 )
12 .unwrap();
13 let node01 = taffy
14 .new_with_children(
15 taffy::style::Style {
16 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), ..Default::default() },
17 ..Default::default()
18 },
19 &[],
20 )
21 .unwrap();
22 let node0 = taffy
23 .new_with_children(
24 taffy::style::Style {
25 position_type: taffy::style::PositionType::Absolute,
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::Percent(1f32),
28 height: taffy::style::Dimension::Points(50f32),
29 ..Default::default()
30 },
31 position: taffy::geometry::Rect {
32 left: taffy::style::Dimension::Percent(0.5f32),
33 ..Default::default()
34 },
35 ..Default::default()
36 },
37 &[node00, node01],
38 )
39 .unwrap();
40 let node = taffy
41 .new_with_children(
42 taffy::style::Style {
43 flex_direction: taffy::style::FlexDirection::Column,
44 size: taffy::geometry::Size {
45 width: taffy::style::Dimension::Points(60f32),
46 height: taffy::style::Dimension::Points(50f32),
47 ..Default::default()
48 },
49 ..Default::default()
50 },
51 &[node0],
52 )
53 .unwrap();
54 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
55 assert_eq!(taffy.layout(node).unwrap().size.width, 60f32);
56 assert_eq!(taffy.layout(node).unwrap().size.height, 50f32);
57 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
58 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
59 assert_eq!(taffy.layout(node0).unwrap().size.width, 60f32);
60 assert_eq!(taffy.layout(node0).unwrap().size.height, 50f32);
61 assert_eq!(taffy.layout(node0).unwrap().location.x, 30f32);
62 assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
63 assert_eq!(taffy.layout(node00).unwrap().size.width, 30f32);
64 assert_eq!(taffy.layout(node00).unwrap().size.height, 50f32);
65 assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
66 assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32);
67 assert_eq!(taffy.layout(node01).unwrap().size.width, 30f32);
68 assert_eq!(taffy.layout(node01).unwrap().size.height, 50f32);
69 assert_eq!(taffy.layout(node01).unwrap().location.x, 30f32);
70 assert_eq!(taffy.layout(node01).unwrap().location.y, 0f32);
71}