gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

⎇ c154b8aa719da0d6f8636b123765a47fa40a3306 tests/generated/flex/flex_grow_child.rs Rust · 67 líneas · 2.8 KB Historia Quién tocó qué crudo

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

1#[test]
2fn flex_grow_child() {
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            flex_grow: 1f32,
9            flex_basis: taffy::style::Dimension::Length(0f32),
10            size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
11            ..Default::default()
12        })
13        .unwrap();
14    let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
15    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
16    println!("\nComputed tree:");
17    taffy.print_tree(node);
18    println!();
19    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
20    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
21    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
22    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
23    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
24    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
25    #[cfg(feature = "content_size")]
26    assert_eq!(
27        layout.scroll_width(),
28        0f32,
29        "scroll_width of node {:?}. Expected {}. Actual {}",
30        node,
31        0f32,
32        layout.scroll_width()
33    );
34    #[cfg(feature = "content_size")]
35    assert_eq!(
36        layout.scroll_height(),
37        0f32,
38        "scroll_height of node {:?}. Expected {}. Actual {}",
39        node,
40        0f32,
41        layout.scroll_height()
42    );
43    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
44    let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
45    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
46    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
47    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
48    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
49    #[cfg(feature = "content_size")]
50    assert_eq!(
51        layout.scroll_width(),
52        0f32,
53        "scroll_width of node {:?}. Expected {}. Actual {}",
54        node0,
55        0f32,
56        layout.scroll_width()
57    );
58    #[cfg(feature = "content_size")]
59    assert_eq!(
60        layout.scroll_height(),
61        0f32,
62        "scroll_height of node {:?}. Expected {}. Actual {}",
63        node0,
64        0f32,
65        layout.scroll_height()
66    );
67}