tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definitions

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/padding_align_end_child.rs Rust · 48 lines · 2.0 KB History Who touched what raw

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

1#[test]
2fn padding_align_end_child() {
3    let mut stretch = stretch::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch::style::Style {
7                size: stretch::geometry::Size {
8                    width: stretch::style::Dimension::Points(100f32),
9                    height: stretch::style::Dimension::Points(100f32),
10                    ..Default::default()
11                },
12                padding: stretch::geometry::Rect {
13                    start: stretch::style::Dimension::Points(20f32),
14                    end: stretch::style::Dimension::Points(20f32),
15                    top: stretch::style::Dimension::Points(20f32),
16                    bottom: stretch::style::Dimension::Points(20f32),
17                    ..Default::default()
18                },
19                ..Default::default()
20            },
21            vec![],
22        )
23        .unwrap();
24    let node = stretch
25        .new_node(
26            stretch::style::Style {
27                align_items: stretch::style::AlignItems::FlexEnd,
28                justify_content: stretch::style::JustifyContent::FlexEnd,
29                size: stretch::geometry::Size {
30                    width: stretch::style::Dimension::Points(200f32),
31                    height: stretch::style::Dimension::Points(200f32),
32                    ..Default::default()
33                },
34                ..Default::default()
35            },
36            vec![node0],
37        )
38        .unwrap();
39    stretch.compute_layout(node, stretch::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}