gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1111HTML 1039Markdown 12TOML 94524 Definiciones

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

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

1#[test]
2fn flex_root_ignored() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_node(
6            taffy::style::Style {
7                flex_grow: 1f32,
8                flex_basis: taffy::style::Dimension::Points(200f32),
9                ..Default::default()
10            },
11            &[],
12        )
13        .unwrap();
14    let node1 = taffy
15        .new_node(
16            taffy::style::Style {
17                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() },
18                ..Default::default()
19            },
20            &[],
21        )
22        .unwrap();
23    let node = taffy
24        .new_node(
25            taffy::style::Style {
26                flex_direction: taffy::style::FlexDirection::Column,
27                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
28                min_size: taffy::geometry::Size {
29                    height: taffy::style::Dimension::Points(100f32),
30                    ..Default::default()
31                },
32                max_size: taffy::geometry::Size {
33                    height: taffy::style::Dimension::Points(500f32),
34                    ..Default::default()
35                },
36                ..Default::default()
37            },
38            &[node0, node1],
39        )
40        .unwrap();
41    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
42    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
43    assert_eq!(taffy.layout(node).unwrap().size.height, 300f32);
44    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
45    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
46    assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
47    assert_eq!(taffy.layout(node0).unwrap().size.height, 200f32);
48    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
49    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
50    assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32);
51    assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32);
52    assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
53    assert_eq!(taffy.layout(node1).unwrap().location.y, 200f32);
54}