tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definitions

⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f tests/generated/flex/display_none_only_node.rs Rust · 56 lines · 2.5 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 display_none_only_node__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node = taffy
8        .new_leaf(taffy::style::Style {
9            display: taffy::style::Display::None,
10            size: taffy::geometry::Size {
11                width: taffy::style::Dimension::from_length(100f32),
12                height: taffy::style::Dimension::from_length(100f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
18    println!("\nComputed tree:");
19    taffy.print_tree(node);
20    println!();
21    let layout = taffy.layout(node).unwrap();
22    let Layout { size, location, .. } = layout;
23    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
24    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
25    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
26    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
27}
28
29#[test]
30#[allow(non_snake_case)]
31fn display_none_only_node__content_box() {
32    #[allow(unused_imports)]
33    use taffy::{prelude::*, Layout};
34    let mut taffy = crate::new_test_tree();
35    let node = taffy
36        .new_leaf(taffy::style::Style {
37            display: taffy::style::Display::None,
38            box_sizing: taffy::style::BoxSizing::ContentBox,
39            size: taffy::geometry::Size {
40                width: taffy::style::Dimension::from_length(100f32),
41                height: taffy::style::Dimension::from_length(100f32),
42            },
43            ..Default::default()
44        })
45        .unwrap();
46    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
47    println!("\nComputed tree:");
48    taffy.print_tree(node);
49    println!();
50    let layout = taffy.layout(node).unwrap();
51    let Layout { size, location, .. } = layout;
52    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
53    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
54    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
55    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
56}