1#[test]
2fn absolute_layout_width_height_start_top() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_node(
6 taffy::style::Style {
7 position_type: taffy::style::PositionType::Absolute,
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Points(10f32),
10 height: taffy::style::Dimension::Points(10f32),
11 ..Default::default()
12 },
13 position: taffy::geometry::Rect {
14 start: taffy::style::Dimension::Points(10f32),
15 top: taffy::style::Dimension::Points(10f32),
16 ..Default::default()
17 },
18 ..Default::default()
19 },
20 &[],
21 )
22 .unwrap();
23 let node = taffy
24 .new_node(
25 taffy::style::Style {
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::Points(100f32),
28 height: taffy::style::Dimension::Points(100f32),
29 ..Default::default()
30 },
31 ..Default::default()
32 },
33 &[node0],
34 )
35 .unwrap();
36 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
37 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
38 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
39 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
40 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
41 assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32);
42 assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
43 assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32);
44 assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32);
45}