⎇ 39cd0fcbbda7cd38cc6316e7339b1f3aed29e99f
tests/generated/padding_center_child.rs
Historia
Quién tocó qué
crudo
Rename `new_node` to `new_with_children` (#142)
1#[test]
2fn padding_center_child() {
3 let mut taffy = taffy::Taffy::new();
4 let node0 = taffy
5 .new_with_children(
6 taffy::style::FlexboxLayout {
7 size: taffy::geometry::Size {
8 width: taffy::style::Dimension::Points(10f32),
9 height: taffy::style::Dimension::Points(10f32),
10 ..Default::default()
11 },
12 ..Default::default()
13 },
14 &[],
15 )
16 .unwrap();
17 let node = taffy
18 .new_with_children(
19 taffy::style::FlexboxLayout {
20 align_items: taffy::style::AlignItems::Center,
21 justify_content: taffy::style::JustifyContent::Center,
22 size: taffy::geometry::Size {
23 width: taffy::style::Dimension::Points(100f32),
24 height: taffy::style::Dimension::Points(100f32),
25 ..Default::default()
26 },
27 padding: taffy::geometry::Rect {
28 start: taffy::style::Dimension::Points(10f32),
29 end: taffy::style::Dimension::Points(20f32),
30 top: taffy::style::Dimension::Points(10f32),
31 bottom: taffy::style::Dimension::Points(20f32),
32 ..Default::default()
33 },
34 ..Default::default()
35 },
36 &[node0],
37 )
38 .unwrap();
39 taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
40 assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
41 assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
42 assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
43 assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
44 assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32);
45 assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
46 assert_eq!(taffy.layout(node0).unwrap().location.x, 40f32);
47 assert_eq!(taffy.layout(node0).unwrap().location.y, 40f32);
48}