gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5364Rust 86Markdown 12TOML 91841 Definitions

⎇ 0.1.x tests/generated/flex_grow_within_constrained_max_column.rs Rust · 50 lines · 2.0 KB History Who touched what raw

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

1#[test]
2fn flex_grow_within_constrained_max_column() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_node(
6            taffy::style::Style {
7                flex_shrink: 1f32,
8                flex_basis: taffy::style::Dimension::Points(100f32),
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(50f32), ..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                max_size: taffy::geometry::Size {
29                    height: taffy::style::Dimension::Points(100f32),
30                    ..Default::default()
31                },
32                ..Default::default()
33            },
34            &[node0, node1],
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, 100f32);
43    assert_eq!(taffy.layout(node0).unwrap().size.height, 67f32);
44    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
45    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
46    assert_eq!(taffy.layout(node1).unwrap().size.width, 100f32);
47    assert_eq!(taffy.layout(node1).unwrap().size.height, 33f32);
48    assert_eq!(taffy.layout(node1).unwrap().location.x, 0f32);
49    assert_eq!(taffy.layout(node1).unwrap().location.y, 67f32);
50}