gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

⎇ 0.5.x tests/generated/leaf/leaf_overflow_scrollbars_overridden_by_available_space.rs Rust · 78 líneas · 3.1 KB Historia Quién tocó qué crudo

Fix typos. (#611) f1e4edab9 · Bruce Mitchener ·

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