gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 496HTML 245JavaScript 8CSS 61214 Definiciones

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

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

1#[test]
2fn max_width_overrides_width_on_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(taffy::style::Style {
8            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(200f32), height: auto() },
9            max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
10            ..Default::default()
11        })
12        .unwrap();
13    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
14    println!("\nComputed tree:");
15    taffy.print_tree(node);
16    println!();
17    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
18    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
19    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
20    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
21    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
22    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
23    #[cfg(feature = "content_size")]
24    assert_eq!(
25        layout.scroll_width(),
26        0f32,
27        "scroll_width of node {:?}. Expected {}. Actual {}",
28        node,
29        0f32,
30        layout.scroll_width()
31    );
32    #[cfg(feature = "content_size")]
33    assert_eq!(
34        layout.scroll_height(),
35        0f32,
36        "scroll_height of node {:?}. Expected {}. Actual {}",
37        node,
38        0f32,
39        layout.scroll_height()
40    );
41}