gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Sutichaykuna

⎇ 0.2.x tests/generated/flex_wrap_align_stretch_fits_one_row.rs Rust · 49 siq'ikuna · 2.0 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

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