gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1090HTML 1022Markdown 12TOML 84418 Definiciones

⎇ a1e91740880b61f1c39c9114b628ff09655141a9 tests/generated/flex_grow_within_constrained_max_width.rs Rust · 53 líneas · 2.1 KB Historia Quién tocó qué crudo

Rename generated files (#80) 78c5e05ef · Andreas Weibye ·

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