tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1090HTML 1022Markdown 12TOML 84418 Definiciones

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