gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

⎇ 477ff4aff498cbae4cdfbf0cda1ee5b04c784f08 tests/generated/flex/flex_grow_within_constrained_min_max_column.rs Rust · 100 líneas · 4.2 KB Historia Quién tocó qué crudo

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

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