tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1076HTML 1008Markdown 12TOML 83208 Definiciones

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/flex_wrap_align_stretch_fits_one_row.rs Rust · 49 líneas · 2.0 KB Historia Quién tocó qué crudo

index: update tests to API changes 48c69198a · msiglreith ·

1#[test]
2fn flex_wrap_align_stretch_fits_one_row() {
3    let mut stretch = stretch::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch::style::Style {
7                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(50f32), ..Default::default() },
8                ..Default::default()
9            },
10            vec![],
11        )
12        .unwrap();
13    let node1 = stretch
14        .new_node(
15            stretch::style::Style {
16                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(50f32), ..Default::default() },
17                ..Default::default()
18            },
19            vec![],
20        )
21        .unwrap();
22    let node = stretch
23        .new_node(
24            stretch::style::Style {
25                flex_wrap: stretch::style::FlexWrap::Wrap,
26                size: stretch::geometry::Size {
27                    width: stretch::style::Dimension::Points(150f32),
28                    height: stretch::style::Dimension::Points(100f32),
29                    ..Default::default()
30                },
31                ..Default::default()
32            },
33            vec![node0, node1],
34        )
35        .unwrap();
36    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
37    assert_eq!(stretch.layout(node).unwrap().size.width, 150f32);
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, 50f32);
42    assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
43    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
44    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
45    assert_eq!(stretch.layout(node1).unwrap().size.width, 50f32);
46    assert_eq!(stretch.layout(node1).unwrap().size.height, 100f32);
47    assert_eq!(stretch.layout(node1).unwrap().location.x, 50f32);
48    assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
49}