tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Sutichaykuna

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