tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Definiciones

⎇ b746ac4f346dde8a2b6f85d3a428c02a2342f099 tests/generated/flex/min_width_overrides_width_on_root.rs Rust · 86 líneas · 3.6 KB Historia Quién tocó qué crudo

Implement `box-sizing: content-box` (#675) a4976764b · Nico Burns ·

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