gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 252HTML 238TOML 3CSS 1626 Definiciones

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/absolute_layout_justify_content_center.rs Rust · 41 líneas · 1.7 KB Historia Quién tocó qué crudo

rename stretch to stretch2 99945cfc7 · elbaro ·

1#[test]
2fn absolute_layout_justify_content_center() {
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(60f32),
10                    height: stretch2::style::Dimension::Points(40f32),
11                    ..Default::default()
12                },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node = stretch
19        .new_node(
20            stretch2::style::Style {
21                justify_content: stretch2::style::JustifyContent::Center,
22                size: stretch2::geometry::Size {
23                    width: stretch2::style::Dimension::Points(110f32),
24                    height: stretch2::style::Dimension::Points(100f32),
25                    ..Default::default()
26                },
27                ..Default::default()
28            },
29            &[node0],
30        )
31        .unwrap();
32    stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
33    assert_eq!(stretch.layout(node).unwrap().size.width, 110f32);
34    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
35    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
36    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
37    assert_eq!(stretch.layout(node0).unwrap().size.width, 60f32);
38    assert_eq!(stretch.layout(node0).unwrap().size.height, 40f32);
39    assert_eq!(stretch.layout(node0).unwrap().location.x, 25f32);
40    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
41}