gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Sutichaykuna

⎇ 0.1.x tests/generated/justify_content_row_max_width_and_margin.rs Rust · 38 siq'ikuna · 1.7 KB Ñawpa willay Pi imata llamkarqan ch'uya

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

1#[test]
2fn justify_content_row_max_width_and_margin() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_node(
6            taffy::style::Style {
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(20f32),
9                    height: taffy::style::Dimension::Points(20f32),
10                    ..Default::default()
11                },
12                margin: taffy::geometry::Rect { start: taffy::style::Dimension::Points(100f32), ..Default::default() },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node = taffy
19        .new_node(
20            taffy::style::Style {
21                justify_content: taffy::style::JustifyContent::Center,
22                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(100f32), ..Default::default() },
23                max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(80f32), ..Default::default() },
24                ..Default::default()
25            },
26            &[node0],
27        )
28        .unwrap();
29    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
30    assert_eq!(taffy.layout(node).unwrap().size.width, 80f32);
31    assert_eq!(taffy.layout(node).unwrap().size.height, 20f32);
32    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
33    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
34    assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32);
35    assert_eq!(taffy.layout(node0).unwrap().size.height, 20f32);
36    assert_eq!(taffy.layout(node0).unwrap().location.x, 90f32);
37    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
38}