gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1118HTML 1044Markdown 12TOML 94787 Definiciones

⎇ 48e4800f14c6af5cd26275fb570d11b93e279654 tests/generated/flex/display_none_fixed_size.rs Rust · 48 líneas · 2.6 KB Historia Quién tocó qué crudo

Sort test fixtures and generated tests into folders (#514) 24b8faf43 · aemreaydin ·

1#[test]
2fn display_none_fixed_size() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout};
5    let mut taffy = taffy::Taffy::new();
6    let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
7    let node1 = taffy
8        .new_leaf(taffy::style::Style {
9            display: taffy::style::Display::None,
10            size: taffy::geometry::Size {
11                width: taffy::style::Dimension::Length(20f32),
12                height: taffy::style::Dimension::Length(20f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    let node = taffy
18        .new_with_children(
19            taffy::style::Style {
20                size: taffy::geometry::Size {
21                    width: taffy::style::Dimension::Length(100f32),
22                    height: taffy::style::Dimension::Length(100f32),
23                },
24                ..Default::default()
25            },
26            &[node0, node1],
27        )
28        .unwrap();
29    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
30    println!("\nComputed tree:");
31    taffy::util::print_tree(&taffy, node);
32    println!();
33    let Layout { size, location, .. } = taffy.layout(node).unwrap();
34    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
35    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
36    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
39    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
40    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
41    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
42    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
43    let Layout { size, location, .. } = taffy.layout(node1).unwrap();
44    assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
45    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
46    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
47    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
48}