tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 9TOML 3CSS 1345 Definitions

⎇ d67e82255da07928c7e415ea7364529d204bbaf9 tests/generated/flex_wrap_align_stretch_fits_one_row.rs Rust · 55 lines · 2.1 KB History Who touched what raw

Fix formatting d67e82255 · elbaro ·

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