tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Definiciones

⎇ 39cd0fcbbda7cd38cc6316e7339b1f3aed29e99f tests/generated/absolute_layout_width_height_start_top_end_bottom.rs Rust · 47 líneas · 2.0 KB Historia Quién tocó qué crudo

Rename `new_node` to `new_with_children` (#142) 5d00d8fb9 · Andreas Weibye ·

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::undefined()).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}