⎇ 0.1.x
tests/generated/relative_position_should_not_nudge_siblings.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn relative_position_should_not_nudge_siblings() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_node(
6 taffy::style::Style {
7 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() },
8 position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() },
9 ..Default::default()
10 },
11 &[],
12 )
13 .unwrap();
14 let node1 = taffy
15 .new_node(
16 taffy::style::Style {
17 size: taffy::geometry::Size { height: taffy::style::Dimension::Points(10f32), ..Default::default() },
18 position: taffy::geometry::Rect { top: taffy::style::Dimension::Points(15f32), ..Default::default() },
19 ..Default::default()
20 },
21 &[],
22 )
23 .unwrap();
24 let node = taffy
25 .new_node(
26 taffy::style::Style {
27 flex_direction: taffy::style::FlexDirection::Column,
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Points(100f32),
30 height: taffy::style::Dimension::Points(100f32),
31 ..Default::default()
32 },
33 ..Default::default()
34 },
35 &[node0, node1],
36 )
37 .unwrap();
38 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
39 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
40 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
41 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
42 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
43 assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
44 assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
45 assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
46 assert_eq!(taffy.layout(node0).unwrap().location.y, 15f32);
47 assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32);
48 assert_eq!(taffy.layout(node1).unwrap().size.height, 10f32);
49 assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
50 assert_eq!(taffy.layout(node1).unwrap().location.y, 25f32);
51}