gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 238TOML 3CSS 11131 Sutichaykuna

⎇ 48e4800f14c6af5cd26275fb570d11b93e279654 tests/generated/flex/justify_content_row_min_width_and_margin.rs Rust · 45 siq'ikuna · 2.2 KB Ñawpa willay Pi imata llamkarqan ch'uya

Sort test fixtures and generated tests into folders (#514) 24b8faf43 · aemreaydin ·

1#[test]
2fn justify_content_row_min_width_and_margin() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout};
5    let mut taffy = taffy::Taffy::new();
6    let node0 = taffy
7        .new_leaf(taffy::style::Style {
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Length(20f32),
10                height: taffy::style::Dimension::Length(20f32),
11            },
12            margin: taffy::geometry::Rect {
13                left: taffy::style::LengthPercentageAuto::Length(10f32),
14                right: zero(),
15                top: zero(),
16                bottom: zero(),
17            },
18            ..Default::default()
19        })
20        .unwrap();
21    let node = taffy
22        .new_with_children(
23            taffy::style::Style {
24                justify_content: Some(taffy::style::JustifyContent::Center),
25                min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
26                ..Default::default()
27            },
28            &[node0],
29        )
30        .unwrap();
31    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
32    println!("\nComputed tree:");
33    taffy::util::print_tree(&taffy, node);
34    println!();
35    let Layout { size, location, .. } = taffy.layout(node).unwrap();
36    assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
37    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
38    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
39    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
40    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
41    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
42    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
43    assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node0, 20f32, location.x);
44    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
45}