gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 245JavaScript 8CSS 61138 Definiciones

⎇ a1e91740880b61f1c39c9114b628ff09655141a9 tests/generated/absolute_layout_width_height_start_top.rs Rust · 45 líneas · 1.8 KB Historia Quién tocó qué crudo

Rename generated files (#80) 78c5e05ef · Andreas Weibye ·

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