tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Sutichaykuna

⎇ c83608da41161141b31ab5bf6961352e7870c505 tests/generated/absolute_layout_width_height_start_top_end_bottom.rs Rust · 47 siq'ikuna · 2.0 KB Ñawpa willay Pi imata llamkarqan ch'uya

Make library more usable in a `const` context (#203) 3535699e0 · Alice Cecile ·

1#[test]
2fn absolute_layout_width_height_start_top_end_bottom() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::FlexboxLayout {
7                position_type: taffy::style::PositionType::Absolute,
8                size: taffy::geometry::Size {
9                    width: taffy::style::Dimension::Points(10f32),
10                    height: taffy::style::Dimension::Points(10f32),
11                    ..Default::default()
12                },
13                position: taffy::geometry::Rect {
14                    start: taffy::style::Dimension::Points(10f32),
15                    end: taffy::style::Dimension::Points(10f32),
16                    top: taffy::style::Dimension::Points(10f32),
17                    bottom: taffy::style::Dimension::Points(10f32),
18                    ..Default::default()
19                },
20                ..Default::default()
21            },
22            &[],
23        )
24        .unwrap();
25    let node = taffy
26        .new_with_children(
27            taffy::style::FlexboxLayout {
28                size: taffy::geometry::Size {
29                    width: taffy::style::Dimension::Points(100f32),
30                    height: taffy::style::Dimension::Points(100f32),
31                    ..Default::default()
32                },
33                ..Default::default()
34            },
35            &[node0],
36        )
37        .unwrap();
38    taffy.compute_layout(node, taffy::geometry::Size::NONE).unwrap();
39    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
40    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
41    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
42    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
43    assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32);
44    assert_eq!(taffy.layout(node0).unwrap().size.height, 10f32);
45    assert_eq!(taffy.layout(node0).unwrap().location.x, 10f32);
46    assert_eq!(taffy.layout(node0).unwrap().location.y, 10f32);
47}