tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 229Rust 8TOML 3CSS 1310 Definiciones

⎇ cd73db35cfa2b31555a796e7972cd97a45554e17 tests/generated/flex/absolute_layout_in_wrap_reverse_column_container.rs Rust · 82 líneas · 3.3 KB Historia Quién tocó qué crudo

Rename Taffy struct to TaffyTree (#580) 17235ffa2 · Nico Burns ·

1#[test]
2fn absolute_layout_in_wrap_reverse_column_container() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout, TaffyTree};
5    let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::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(20f32),
11                height: taffy::style::Dimension::Length(20f32),
12            },
13            ..Default::default()
14        })
15        .unwrap();
16    let node = taffy
17        .new_with_children(
18            taffy::style::Style {
19                flex_direction: taffy::style::FlexDirection::Column,
20                flex_wrap: taffy::style::FlexWrap::WrapReverse,
21                size: taffy::geometry::Size {
22                    width: taffy::style::Dimension::Length(100f32),
23                    height: taffy::style::Dimension::Length(100f32),
24                },
25                ..Default::default()
26            },
27            &[node0],
28        )
29        .unwrap();
30    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
31    println!("\nComputed tree:");
32    taffy.print_tree(node);
33    println!();
34    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
35    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
36    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
37    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, 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    #[cfg(feature = "content_size")]
41    assert_eq!(
42        layout.scroll_width(),
43        0f32,
44        "scroll_width of node {:?}. Expected {}. Actual {}",
45        node,
46        0f32,
47        layout.scroll_width()
48    );
49    #[cfg(feature = "content_size")]
50    assert_eq!(
51        layout.scroll_height(),
52        0f32,
53        "scroll_height of node {:?}. Expected {}. Actual {}",
54        node,
55        0f32,
56        layout.scroll_height()
57    );
58    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
59    let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
60    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
61    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
62    assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node0, 80f32, location.x);
63    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
64    #[cfg(feature = "content_size")]
65    assert_eq!(
66        layout.scroll_width(),
67        0f32,
68        "scroll_width of node {:?}. Expected {}. Actual {}",
69        node0,
70        0f32,
71        layout.scroll_width()
72    );
73    #[cfg(feature = "content_size")]
74    assert_eq!(
75        layout.scroll_height(),
76        0f32,
77        "scroll_height of node {:?}. Expected {}. Actual {}",
78        node0,
79        0f32,
80        layout.scroll_height()
81    );
82}