tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f tests/generated/flex/display_none_absolute_child.rs Rust · 117 siq'ikuna · 6.1 KB Ñawpa willay Pi imata llamkarqan ch'uya

Use tagged pointer to represent size/length values (#769) afa6437b0 · Nico Burns ·

1#[test]
2#[allow(non_snake_case)]
3fn display_none_absolute_child__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
8    let node1 = taffy
9        .new_leaf(taffy::style::Style {
10            display: taffy::style::Display::None,
11            position: taffy::style::Position::Absolute,
12            size: taffy::geometry::Size {
13                width: taffy::style::Dimension::from_length(20f32),
14                height: taffy::style::Dimension::from_length(20f32),
15            },
16            inset: taffy::geometry::Rect { left: length(10f32), right: auto(), top: length(10f32), bottom: auto() },
17            ..Default::default()
18        })
19        .unwrap();
20    let node = taffy
21        .new_with_children(
22            taffy::style::Style {
23                size: taffy::geometry::Size {
24                    width: taffy::style::Dimension::from_length(100f32),
25                    height: taffy::style::Dimension::from_length(100f32),
26                },
27                ..Default::default()
28            },
29            &[node0, node1],
30        )
31        .unwrap();
32    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
33    println!("\nComputed tree:");
34    taffy.print_tree(node);
35    println!();
36    let layout = taffy.layout(node).unwrap();
37    let Layout { size, location, .. } = layout;
38    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
39    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, 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 = taffy.layout(node0).unwrap();
43    let Layout { size, location, .. } = layout;
44    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
45    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
46    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
47    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
48    let layout = taffy.layout(node1).unwrap();
49    let Layout { size, location, .. } = layout;
50    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
51    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
52    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
53    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
54}
55
56#[test]
57#[allow(non_snake_case)]
58fn display_none_absolute_child__content_box() {
59    #[allow(unused_imports)]
60    use taffy::{prelude::*, Layout};
61    let mut taffy = crate::new_test_tree();
62    let node0 = taffy
63        .new_leaf(taffy::style::Style {
64            box_sizing: taffy::style::BoxSizing::ContentBox,
65            flex_grow: 1f32,
66            ..Default::default()
67        })
68        .unwrap();
69    let node1 = taffy
70        .new_leaf(taffy::style::Style {
71            display: taffy::style::Display::None,
72            box_sizing: taffy::style::BoxSizing::ContentBox,
73            position: taffy::style::Position::Absolute,
74            size: taffy::geometry::Size {
75                width: taffy::style::Dimension::from_length(20f32),
76                height: taffy::style::Dimension::from_length(20f32),
77            },
78            inset: taffy::geometry::Rect { left: length(10f32), right: auto(), top: length(10f32), bottom: auto() },
79            ..Default::default()
80        })
81        .unwrap();
82    let node = taffy
83        .new_with_children(
84            taffy::style::Style {
85                box_sizing: taffy::style::BoxSizing::ContentBox,
86                size: taffy::geometry::Size {
87                    width: taffy::style::Dimension::from_length(100f32),
88                    height: taffy::style::Dimension::from_length(100f32),
89                },
90                ..Default::default()
91            },
92            &[node0, node1],
93        )
94        .unwrap();
95    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
96    println!("\nComputed tree:");
97    taffy.print_tree(node);
98    println!();
99    let layout = taffy.layout(node).unwrap();
100    let Layout { size, location, .. } = layout;
101    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
102    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
103    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
104    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
105    let layout = taffy.layout(node0).unwrap();
106    let Layout { size, location, .. } = layout;
107    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
108    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
109    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
110    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
111    let layout = taffy.layout(node1).unwrap();
112    let Layout { size, location, .. } = layout;
113    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
114    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
115    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
116    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
117}