gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1061HTML 997Markdown 12TOML 83120 Definiciones

⎇ 0.1.x tests/generated/display_none_with_margin.rs Rust · 52 líneas · 2.2 KB Historia Quién tocó qué crudo

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

1#[test]
2fn display_none_with_margin() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_node(
6            taffy::style::Style {
7                display: taffy::style::Display::None,
8                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(20f32),
10                    height: taffy::style::Dimension::Points(20f32),
11                    ..Default::default()
12                },
13                margin: taffy::geometry::Rect {
14                    start: taffy::style::Dimension::Points(10f32),
15                    end: taffy::style::Dimension::Points(10f32),
16                    top: taffy::style::Dimension::Points(10f32),
17                    bottom: taffy::style::Dimension::Points(10f32),
18                    ..Default::default()
19                },
20                ..Default::default()
21            },
22            &[],
23        )
24        .unwrap();
25    let node1 = taffy.new_node(taffy::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap();
26    let node = taffy
27        .new_node(
28            taffy::style::Style {
29                size: taffy::geometry::Size {
30                    width: taffy::style::Dimension::Points(100f32),
31                    height: taffy::style::Dimension::Points(100f32),
32                    ..Default::default()
33                },
34                ..Default::default()
35            },
36            &[node0, node1],
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, 0f32);
45    assert_eq!(taffy.layout(node0).unwrap().size.height, 0f32);
46    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
47    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
48    assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32);
49    assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32);
50    assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
51    assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
52}