gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5334Rust 85Markdown 12TOML 91813 Sutichaykuna

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/absolute_layout_width_height_start_top_end_bottom.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 absolute_layout_width_height_start_top_end_bottom() {
3    let layout = stretch::node::Node::new(
4        stretch::style::Style {
5            size: stretch::geometry::Size {
6                width: stretch::style::Dimension::Points(100f32),
7                height: stretch::style::Dimension::Points(100f32),
8                ..Default::default()
9            },
10            ..Default::default()
11        },
12        vec![&stretch::node::Node::new(
13            stretch::style::Style {
14                position_type: stretch::style::PositionType::Absolute,
15                size: stretch::geometry::Size {
16                    width: stretch::style::Dimension::Points(10f32),
17                    height: stretch::style::Dimension::Points(10f32),
18                    ..Default::default()
19                },
20                position: stretch::geometry::Rect {
21                    start: stretch::style::Dimension::Points(10f32),
22                    end: stretch::style::Dimension::Points(10f32),
23                    top: stretch::style::Dimension::Points(10f32),
24                    bottom: stretch::style::Dimension::Points(10f32),
25                    ..Default::default()
26                },
27                ..Default::default()
28            },
29            vec![],
30        )],
31    )
32    .compute_layout(stretch::geometry::Size::undefined())
33    .unwrap();
34    assert_eq!(layout.size.width, 100f32);
35    assert_eq!(layout.size.height, 100f32);
36    assert_eq!(layout.location.x, 0f32);
37    assert_eq!(layout.location.y, 0f32);
38    assert_eq!(layout.children[0usize].size.width, 10f32);
39    assert_eq!(layout.children[0usize].size.height, 10f32);
40    assert_eq!(layout.children[0usize].location.x, 10f32);
41    assert_eq!(layout.children[0usize].location.y, 10f32);
42}