tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Sutichaykuna

⎇ d67e82255da07928c7e415ea7364529d204bbaf9 tests/generated/padding_flex_child.rs Rust · 46 siq'ikuna · 1.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

Fix formatting d67e82255 · elbaro ·

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