tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 709HTML 662Markdown 12TOML 62348 Sutichaykuna

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

Rename Rect field start->left end->right (#257) ca514f6c8 · Nico Burns ·

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::Style {
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                    left: taffy::style::Dimension::Points(10f32),
15                    right: 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::Style {
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::MAX_CONTENT).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}