gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1086HTML 1018Markdown 12TOML 84406 Sutichaykuna

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/padding_align_end_child.rs Rust · 48 siq'ikuna · 2.0 KB Ñawpa willay Pi imata llamkarqan ch'uya

rename stretch to stretch2 99945cfc7 · elbaro ·

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