gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 31441 Definiciones

⎇ 0.2.x tests/generated/padding_center_child.rs Rust · 48 líneas · 2.0 KB Historia Quién tocó qué crudo

Rename Rect field start->left end->right (#257) ca514f6c8 · Nico Burns ·

1#[test]
2fn padding_center_child() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
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::Style {
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                    left: taffy::style::Dimension::Points(10f32),
29                    right: 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::MAX_CONTENT).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}