tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 979HTML 924Markdown 12TOML 82994 Sutichaykuna

⎇ 6e9ad8ea330ed91c1fbe3169f972ccebd374f85e tests/generated/margin_auto_bottom.rs Rust · 58 siq'ikuna · 2.4 KB Ñawpa willay Pi imata llamkarqan ch'uya

index: update tests to API changes a1b7dbfa3 · msiglreith ·

1#[test]
2fn margin_auto_bottom() {
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(50f32),
9                    height: stretch::style::Dimension::Points(50f32),
10                    ..Default::default()
11                },
12                margin: stretch::geometry::Rect { bottom: stretch::style::Dimension::Auto, ..Default::default() },
13                ..Default::default()
14            },
15            vec![],
16        )
17        .unwrap();
18    let node1 = stretch
19        .new_node(
20            stretch::style::Style {
21                size: stretch::geometry::Size {
22                    width: stretch::style::Dimension::Points(50f32),
23                    height: stretch::style::Dimension::Points(50f32),
24                    ..Default::default()
25                },
26                ..Default::default()
27            },
28            vec![],
29        )
30        .unwrap();
31    let node = stretch
32        .new_node(
33            stretch::style::Style {
34                align_items: stretch::style::AlignItems::Center,
35                size: stretch::geometry::Size {
36                    width: stretch::style::Dimension::Points(200f32),
37                    height: stretch::style::Dimension::Points(200f32),
38                    ..Default::default()
39                },
40                ..Default::default()
41            },
42            vec![node0, node1],
43        )
44        .unwrap();
45    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
46    assert_eq!(stretch.layout(node).unwrap().size.width, 200f32);
47    assert_eq!(stretch.layout(node).unwrap().size.height, 200f32);
48    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
49    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
50    assert_eq!(stretch.layout(node0).unwrap().size.width, 50f32);
51    assert_eq!(stretch.layout(node0).unwrap().size.height, 50f32);
52    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
53    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
54    assert_eq!(stretch.layout(node1).unwrap().size.width, 50f32);
55    assert_eq!(stretch.layout(node1).unwrap().size.height, 50f32);
56    assert_eq!(stretch.layout(node1).unwrap().location.x, 50f32);
57    assert_eq!(stretch.layout(node1).unwrap().location.y, 75f32);
58}