gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 231Rust 8TOML 3CSS 1317 Sutichaykuna

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