gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Definiciones

⎇ 0.2.x tests/generated/flex_grow_within_constrained_max_row.rs Rust · 63 líneas · 2.6 KB Historia Quién tocó qué crudo

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

1#[test]
2fn flex_grow_within_constrained_max_row() {
3    let mut taffy = taffy::Taffy::new();
4    let node00 = 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 node01 = taffy
15        .new_with_children(
16            taffy::style::Style {
17                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), ..Default::default() },
18                ..Default::default()
19            },
20            &[],
21        )
22        .unwrap();
23    let node0 = taffy
24        .new_with_children(
25            taffy::style::Style {
26                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() },
27                max_size: taffy::geometry::Size {
28                    width: taffy::style::Dimension::Points(100f32),
29                    ..Default::default()
30                },
31                ..Default::default()
32            },
33            &[node00, node01],
34        )
35        .unwrap();
36    let node = taffy
37        .new_with_children(
38            taffy::style::Style {
39                flex_direction: taffy::style::FlexDirection::Column,
40                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(200f32), ..Default::default() },
41                ..Default::default()
42            },
43            &[node0],
44        )
45        .unwrap();
46    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
47    assert_eq!(taffy.layout(node).unwrap().size.width, 200f32);
48    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
49    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
50    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
51    assert_eq!(taffy.layout(node0).unwrap().size.width, 100f32);
52    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
53    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
54    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
55    assert_eq!(taffy.layout(node00).unwrap().size.width, 67f32);
56    assert_eq!(taffy.layout(node00).unwrap().size.height, 100f32);
57    assert_eq!(taffy.layout(node00).unwrap().location.x, 0f32);
58    assert_eq!(taffy.layout(node00).unwrap().location.y, 0f32);
59    assert_eq!(taffy.layout(node01).unwrap().size.width, 33f32);
60    assert_eq!(taffy.layout(node01).unwrap().size.height, 100f32);
61    assert_eq!(taffy.layout(node01).unwrap().location.x, 67f32);
62    assert_eq!(taffy.layout(node01).unwrap().location.y, 0f32);
63}