gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 10TOML 3CSS 1350 Definitions

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/absolute_layout_width_height_end_bottom.rs Rust · 45 lines · 1.9 KB History Who touched what raw

rename stretch to stretch2 99945cfc7 · elbaro ·

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