tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definiciones

⎇ 39cd0fcbbda7cd38cc6316e7339b1f3aed29e99f tests/generated/margin_auto_left_right_child_bigger_than_parent.rs Rust · 45 líneas · 1.8 KB Historia Quién tocó qué crudo

Rename `new_node` to `new_with_children` (#142) 5d00d8fb9 · Andreas Weibye ·

1#[test]
2fn margin_auto_left_right_child_bigger_than_parent() {
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(72f32),
9                    height: taffy::style::Dimension::Points(72f32),
10                    ..Default::default()
11                },
12                margin: taffy::geometry::Rect {
13                    start: taffy::style::Dimension::Auto,
14                    end: taffy::style::Dimension::Auto,
15                    ..Default::default()
16                },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node = taffy
23        .new_with_children(
24            taffy::style::FlexboxLayout {
25                justify_content: taffy::style::JustifyContent::Center,
26                size: taffy::geometry::Size {
27                    width: taffy::style::Dimension::Points(52f32),
28                    height: taffy::style::Dimension::Points(52f32),
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, 52f32);
38    assert_eq!(taffy.layout(node).unwrap().size.height, 52f32);
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, 52f32);
42    assert_eq!(taffy.layout(node0).unwrap().size.height, 72f32);
43    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
44    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
45}