gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 684HTML 640Markdown 12TOML 62290 Definitions

⎇ 568f643327ec6b4879df0087def7f4e66b6acafb tests/generated/overflow_scrollbars_overriden_by_available_space.rs Rust · 52 lines · 2.7 KB History Who touched what raw

Support `Overflow::Scroll` (#446) daf416438 · Nico Burns ·

1#[test]
2fn overflow_scrollbars_overriden_by_available_space() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout};
5    let mut taffy = taffy::Taffy::new();
6    let node00 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
7    let node0 = taffy
8        .new_with_children(
9            taffy::style::Style {
10                overflow: taffy::geometry::Point {
11                    x: taffy::style::Overflow::Scroll,
12                    y: taffy::style::Overflow::Scroll,
13                },
14                scrollbar_width: 15f32,
15                flex_grow: 1f32,
16                ..Default::default()
17            },
18            &[node00],
19        )
20        .unwrap();
21    let node = taffy
22        .new_with_children(
23            taffy::style::Style {
24                size: taffy::geometry::Size {
25                    width: taffy::style::Dimension::Length(2f32),
26                    height: taffy::style::Dimension::Length(4f32),
27                },
28                ..Default::default()
29            },
30            &[node0],
31        )
32        .unwrap();
33    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
34    println!("\nComputed tree:");
35    taffy::util::print_tree(&taffy, node);
36    println!();
37    let Layout { size, location, .. } = taffy.layout(node).unwrap();
38    assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width);
39    assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height);
40    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
41    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
42    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
43    assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width);
44    assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node0, 4f32, size.height);
45    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
46    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
47    let Layout { size, location, .. } = taffy.layout(node00).unwrap();
48    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width);
49    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height);
50    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
51    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
52}