gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Sutichaykuna

⎇ 0.1.x tests/generated/min_max_percent_no_width_height.rs Rust · 46 siq'ikuna · 1.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

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