gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

⎇ 9950fe891998e1d08e8b79ce5cc6320efda0941f tests/generated/margin_and_flex_column.rs Rust · 36 lines · 1.3 KB History Who touched what raw

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

1#[test]
2fn margin_and_flex_column() {
3    let layout = stretch::node::Node::new(
4        stretch::style::Style {
5            flex_direction: stretch::style::FlexDirection::Column,
6            size: stretch::geometry::Size {
7                width: stretch::style::Dimension::Points(100f32),
8                height: stretch::style::Dimension::Points(100f32),
9                ..Default::default()
10            },
11            ..Default::default()
12        },
13        vec![&stretch::node::Node::new(
14            stretch::style::Style {
15                flex_grow: 1f32,
16                margin: stretch::geometry::Rect {
17                    top: stretch::style::Dimension::Points(10f32),
18                    bottom: stretch::style::Dimension::Points(10f32),
19                    ..Default::default()
20                },
21                ..Default::default()
22            },
23            vec![],
24        )],
25    )
26    .compute_layout(stretch::geometry::Size::undefined())
27    .unwrap();
28    assert_eq!(layout.size.width, 100f32);
29    assert_eq!(layout.size.height, 100f32);
30    assert_eq!(layout.location.x, 0f32);
31    assert_eq!(layout.location.y, 0f32);
32    assert_eq!(layout.children[0usize].size.width, 100f32);
33    assert_eq!(layout.children[0usize].size.height, 80f32);
34    assert_eq!(layout.children[0usize].location.x, 0f32);
35    assert_eq!(layout.children[0usize].location.y, 10f32);
36}