gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 976HTML 921Markdown 12TOML 82979 Definiciones

⎇ 0.5.x tests/generated/flex/measure_root.rs Rust · 44 líneas · 1.7 KB Historia Quién tocó qué crudo

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

1#[test]
2fn measure_root() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout, TaffyTree};
5    let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6    let node = taffy
7        .new_leaf_with_context(
8            taffy::style::Style { ..Default::default() },
9            crate::TextMeasure {
10                text_content: "HHHHHH",
11                writing_mode: crate::WritingMode::Horizontal,
12                _aspect_ratio: None,
13            },
14        )
15        .unwrap();
16    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
17    println!("\nComputed tree:");
18    taffy.print_tree(node);
19    println!();
20    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
21    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
22    assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
23    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
24    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
25    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
26    #[cfg(feature = "content_size")]
27    assert_eq!(
28        layout.scroll_width(),
29        0f32,
30        "scroll_width of node {:?}. Expected {}. Actual {}",
31        node,
32        0f32,
33        layout.scroll_width()
34    );
35    #[cfg(feature = "content_size")]
36    assert_eq!(
37        layout.scroll_height(),
38        0f32,
39        "scroll_height of node {:?}. Expected {}. Actual {}",
40        node,
41        0f32,
42        layout.scroll_height()
43    );
44}