gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1108HTML 1039Markdown 12TOML 74481 Definiciones

⎇ 48e4800f14c6af5cd26275fb570d11b93e279654 tests/generated/flex/absolute_minmax_bottom_right_max.rs Rust · 52 líneas · 2.5 KB Historia Quién tocó qué crudo

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

1#[test]
2fn absolute_minmax_bottom_right_max() {
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            position: taffy::style::Position::Absolute,
9            size: taffy::geometry::Size {
10                width: taffy::style::Dimension::Length(100f32),
11                height: taffy::style::Dimension::Length(100f32),
12            },
13            max_size: taffy::geometry::Size {
14                width: taffy::style::Dimension::Length(40f32),
15                height: taffy::style::Dimension::Length(30f32),
16            },
17            inset: taffy::geometry::Rect {
18                left: auto(),
19                right: taffy::style::LengthPercentageAuto::Length(10f32),
20                top: auto(),
21                bottom: taffy::style::LengthPercentageAuto::Length(10f32),
22            },
23            ..Default::default()
24        })
25        .unwrap();
26    let node = taffy
27        .new_with_children(
28            taffy::style::Style {
29                size: taffy::geometry::Size {
30                    width: taffy::style::Dimension::Length(100f32),
31                    height: taffy::style::Dimension::Length(100f32),
32                },
33                ..Default::default()
34            },
35            &[node0],
36        )
37        .unwrap();
38    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
39    println!("\nComputed tree:");
40    taffy::util::print_tree(&taffy, node);
41    println!();
42    let Layout { size, location, .. } = taffy.layout(node).unwrap();
43    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
44    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
45    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
46    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
47    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
48    assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
49    assert_eq!(size.height, 30f32, "height of node {:?}. Expected {}. Actual {}", node0, 30f32, size.height);
50    assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node0, 50f32, location.x);
51    assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
52}