gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62290 Sutichaykuna

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/min_height.rs Rust · 42 siq'ikuna · 1.7 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

1#[test]
2fn min_height() {
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![
14            &stretch::node::Node::new(
15                stretch::style::Style {
16                    flex_grow: 1f32,
17                    min_size: stretch::geometry::Size {
18                        height: stretch::style::Dimension::Points(60f32),
19                        ..Default::default()
20                    },
21                    ..Default::default()
22                },
23                vec![],
24            ),
25            &stretch::node::Node::new(stretch::style::Style { flex_grow: 1f32, ..Default::default() }, vec![]),
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, 80f32);
36    assert_eq!(layout.children[0usize].location.x, 0f32);
37    assert_eq!(layout.children[0usize].location.y, 0f32);
38    assert_eq!(layout.children[1usize].size.width, 100f32);
39    assert_eq!(layout.children[1usize].size.height, 20f32);
40    assert_eq!(layout.children[1usize].location.x, 0f32);
41    assert_eq!(layout.children[1usize].location.y, 80f32);
42}