gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 500HTML 254C 19JavaScript 81398 Definiciones

⎇ ac3349ce0fd60591d6019a4658dfe84912514e62 tests/generated/margin_auto_bottom.rs Rust · 50 líneas · 2.0 KB Historia Quién tocó qué crudo

[gentest] Split generated tests into separate files. ac3349ce0 · Adam Perry ·

1#[test]
2fn margin_auto_bottom() {
3    let layout = stretch::compute(
4        &stretch::style::Node {
5            align_items: stretch::style::AlignItems::Center,
6            size: stretch::geometry::Size {
7                width: stretch::style::Dimension::Points(200.0000),
8                height: stretch::style::Dimension::Points(200.0000),
9                ..Default::default()
10            },
11            children: vec![
12                stretch::style::Node {
13                    size: stretch::geometry::Size {
14                        width: stretch::style::Dimension::Points(50.0000),
15                        height: stretch::style::Dimension::Points(50.0000),
16                        ..Default::default()
17                    },
18                    margin: stretch::geometry::Rect { bottom: stretch::style::Dimension::Auto, ..Default::default() },
19                    ..Default::default()
20                },
21                stretch::style::Node {
22                    size: stretch::geometry::Size {
23                        width: stretch::style::Dimension::Points(50.0000),
24                        height: stretch::style::Dimension::Points(50.0000),
25                        ..Default::default()
26                    },
27                    ..Default::default()
28                },
29            ],
30            ..Default::default()
31        },
32        stretch::geometry::Size::undefined(),
33    )
34    .unwrap();
35
36    assert_eq!(layout.size.width, 200.0000);
37    assert_eq!(layout.size.height, 200.0000);
38    assert_eq!(layout.location.x, 0.0000);
39    assert_eq!(layout.location.y, 0.0000);
40
41    assert_eq!(layout.children[0].size.width, 50.0000);
42    assert_eq!(layout.children[0].size.height, 50.0000);
43    assert_eq!(layout.children[0].location.x, 0.0000);
44    assert_eq!(layout.children[0].location.y, 0.0000);
45
46    assert_eq!(layout.children[1].size.width, 50.0000);
47    assert_eq!(layout.children[1].size.height, 50.0000);
48    assert_eq!(layout.children[1].location.x, 50.0000);
49    assert_eq!(layout.children[1].location.y, 75.0000);
50}