tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 41214 Sutichaykuna

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/margin_auto_bottom_and_top_justify_center.rs Rust · 62 siq'ikuna · 2.5 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

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