tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 31234 Definiciones

⎇ ca514f6c8ddc2a934f97170227bbe109223c80b8 tests/generated/padding_flex_child.rs Rust · 43 líneas · 1.8 KB Historia Quién tocó qué crudo

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

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