gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

⎇ dff7bef4e12d1cb436e7e50839242170379bd998 tests/generated/flex_grow_within_constrained_max_column.rs Rust · 50 líneas · 2.0 KB Historia Quién tocó qué crudo

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

1#[test]
2fn flex_grow_within_constrained_max_column() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
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_with_children(
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_with_children(
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::MAX_CONTENT).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}