tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 41214 Sutichaykuna

⎇ a149c6b6b8f7d25328e78ba649b76d1841c55d9d tests/generated/border_flex_child.rs Rust · 43 siq'ikuna · 1.8 KB Ñawpa willay Pi imata llamkarqan ch'uya

index: update tests to API changes 48c69198a · msiglreith ·

1#[test]
2fn border_flex_child() {
3    let mut stretch = stretch::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch::style::Style {
7                flex_grow: 1f32,
8                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(10f32), ..Default::default() },
9                ..Default::default()
10            },
11            vec![],
12        )
13        .unwrap();
14    let node = stretch
15        .new_node(
16            stretch::style::Style {
17                size: stretch::geometry::Size {
18                    width: stretch::style::Dimension::Points(100f32),
19                    height: stretch::style::Dimension::Points(100f32),
20                    ..Default::default()
21                },
22                border: stretch::geometry::Rect {
23                    start: stretch::style::Dimension::Points(10f32),
24                    end: stretch::style::Dimension::Points(10f32),
25                    top: stretch::style::Dimension::Points(10f32),
26                    bottom: stretch::style::Dimension::Points(10f32),
27                    ..Default::default()
28                },
29                ..Default::default()
30            },
31            vec![node0],
32        )
33        .unwrap();
34    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
35    assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
36    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
37    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
38    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
39    assert_eq!(stretch.layout(node0).unwrap().size.width, 80f32);
40    assert_eq!(stretch.layout(node0).unwrap().size.height, 80f32);
41    assert_eq!(stretch.layout(node0).unwrap().location.x, 10f32);
42    assert_eq!(stretch.layout(node0).unwrap().location.y, 10f32);
43}