gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definiciones

⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089 tests/generated/flex/nested_overflowing_child.rs Rust · 104 líneas · 4.2 KB Historia Quién tocó qué crudo

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

1#[test]
2fn nested_overflowing_child() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout, TaffyTree};
5    let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6    let node00 = taffy
7        .new_leaf(taffy::style::Style {
8            size: taffy::geometry::Size {
9                width: taffy::style::Dimension::Length(200f32),
10                height: taffy::style::Dimension::Length(200f32),
11            },
12            ..Default::default()
13        })
14        .unwrap();
15    let node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap();
16    let node = taffy
17        .new_with_children(
18            taffy::style::Style {
19                size: taffy::geometry::Size {
20                    width: taffy::style::Dimension::Length(100f32),
21                    height: taffy::style::Dimension::Length(100f32),
22                },
23                ..Default::default()
24            },
25            &[node0],
26        )
27        .unwrap();
28    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
29    println!("\nComputed tree:");
30    taffy.print_tree(node);
31    println!();
32    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
33    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
34    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
35    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
36    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38    #[cfg(feature = "content_size")]
39    assert_eq!(
40        layout.scroll_width(),
41        100f32,
42        "scroll_width of node {:?}. Expected {}. Actual {}",
43        node,
44        100f32,
45        layout.scroll_width()
46    );
47    #[cfg(feature = "content_size")]
48    assert_eq!(
49        layout.scroll_height(),
50        100f32,
51        "scroll_height of node {:?}. Expected {}. Actual {}",
52        node,
53        100f32,
54        layout.scroll_height()
55    );
56    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
57    let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
58    assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
59    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
60    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
61    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
62    #[cfg(feature = "content_size")]
63    assert_eq!(
64        layout.scroll_width(),
65        0f32,
66        "scroll_width of node {:?}. Expected {}. Actual {}",
67        node0,
68        0f32,
69        layout.scroll_width()
70    );
71    #[cfg(feature = "content_size")]
72    assert_eq!(
73        layout.scroll_height(),
74        100f32,
75        "scroll_height of node {:?}. Expected {}. Actual {}",
76        node0,
77        100f32,
78        layout.scroll_height()
79    );
80    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
81    let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
82    assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node00, 200f32, size.width);
83    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node00, 200f32, size.height);
84    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
85    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
86    #[cfg(feature = "content_size")]
87    assert_eq!(
88        layout.scroll_width(),
89        0f32,
90        "scroll_width of node {:?}. Expected {}. Actual {}",
91        node00,
92        0f32,
93        layout.scroll_width()
94    );
95    #[cfg(feature = "content_size")]
96    assert_eq!(
97        layout.scroll_height(),
98        0f32,
99        "scroll_height of node {:?}. Expected {}. Actual {}",
100        node00,
101        0f32,
102        layout.scroll_height()
103    );
104}