tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1061HTML 997Markdown 12TOML 83120 Sutichaykuna

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