tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1118HTML 1044Markdown 12TOML 94787 Definitions

⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2 tests/generated/flex/flex_grow_child.rs Rust · 71 lines · 3.8 KB History Who touched what raw

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

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