tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

⎇ 3de41935b1054f945bfaeb40dfc213cd57366b9b tests/generated/flex_basis_larger_than_content_column.rs Rust · 42 lines · 1.8 KB History Who touched what raw

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

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