gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62536 Sutichaykuna

⎇ 9950fe891998e1d08e8b79ce5cc6320efda0941f tests/generated/margin_auto_bottom.rs Rust · 53 siq'ikuna · 2.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

update tests and benchmarks to use new api 1f8c44154 · Emil Sjölander ·

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