tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 788HTML 740Markdown 12TOML 62536 Definiciones

⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f tests/generated/flex/overflow_scroll_main_axis_justify_content_end.rs Rust · 89 líneas · 4.4 KB Historia Quién tocó qué crudo

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

1#[test]
2#[allow(non_snake_case)]
3fn overflow_scroll_main_axis_justify_content_end__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            flex_shrink: 0f32,
10            size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() },
11            ..Default::default()
12        })
13        .unwrap();
14    let node = taffy
15        .new_with_children(
16            taffy::style::Style {
17                justify_content: Some(taffy::style::JustifyContent::End),
18                size: taffy::geometry::Size {
19                    width: taffy::style::Dimension::from_length(100f32),
20                    height: taffy::style::Dimension::from_length(100f32),
21                },
22                ..Default::default()
23            },
24            &[node0],
25        )
26        .unwrap();
27    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
28    println!("\nComputed tree:");
29    taffy.print_tree(node);
30    println!();
31    let layout = taffy.layout(node).unwrap();
32    let Layout { size, location, .. } = layout;
33    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
34    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
35    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
36    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
37    let layout = taffy.layout(node0).unwrap();
38    let Layout { size, location, .. } = layout;
39    assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
40    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
41    assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x);
42    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
43}
44
45#[test]
46#[allow(non_snake_case)]
47fn overflow_scroll_main_axis_justify_content_end__content_box() {
48    #[allow(unused_imports)]
49    use taffy::{prelude::*, Layout};
50    let mut taffy = crate::new_test_tree();
51    let node0 = taffy
52        .new_leaf(taffy::style::Style {
53            box_sizing: taffy::style::BoxSizing::ContentBox,
54            flex_shrink: 0f32,
55            size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(200f32), height: auto() },
56            ..Default::default()
57        })
58        .unwrap();
59    let node = taffy
60        .new_with_children(
61            taffy::style::Style {
62                box_sizing: taffy::style::BoxSizing::ContentBox,
63                justify_content: Some(taffy::style::JustifyContent::End),
64                size: taffy::geometry::Size {
65                    width: taffy::style::Dimension::from_length(100f32),
66                    height: taffy::style::Dimension::from_length(100f32),
67                },
68                ..Default::default()
69            },
70            &[node0],
71        )
72        .unwrap();
73    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
74    println!("\nComputed tree:");
75    taffy.print_tree(node);
76    println!();
77    let layout = taffy.layout(node).unwrap();
78    let Layout { size, location, .. } = layout;
79    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
80    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
81    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
82    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
83    let layout = taffy.layout(node0).unwrap();
84    let Layout { size, location, .. } = layout;
85    assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
86    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
87    assert_eq!(location.x, -100f32, "x of node {:?}. Expected {}. Actual {}", node0, -100f32, location.x);
88    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
89}