gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 238TOML 3CSS 11131 Definiciones

⎇ a1e91740880b61f1c39c9114b628ff09655141a9 tests/generated/display_none_fixed_size.rs Rust · 45 líneas · 1.9 KB Historia Quién tocó qué crudo

Rename generated files (#80) 78c5e05ef · Andreas Weibye ·

1#[test]
2fn display_none_fixed_size() {
3    let mut sprawl = sprawl::Sprawl::new();
4    let node0 = sprawl.new_node(sprawl::style::Style { flex_grow: 1f32, ..Default::default() }, &[]).unwrap();
5    let node1 = sprawl
6        .new_node(
7            sprawl::style::Style {
8                display: sprawl::style::Display::None,
9                size: sprawl::geometry::Size {
10                    width: sprawl::style::Dimension::Points(20f32),
11                    height: sprawl::style::Dimension::Points(20f32),
12                    ..Default::default()
13                },
14                ..Default::default()
15            },
16            &[],
17        )
18        .unwrap();
19    let node = sprawl
20        .new_node(
21            sprawl::style::Style {
22                size: sprawl::geometry::Size {
23                    width: sprawl::style::Dimension::Points(100f32),
24                    height: sprawl::style::Dimension::Points(100f32),
25                    ..Default::default()
26                },
27                ..Default::default()
28            },
29            &[node0, node1],
30        )
31        .unwrap();
32    sprawl.compute_layout(node, sprawl::geometry::Size::undefined()).unwrap();
33    assert_eq!(sprawl.layout(node).unwrap().size.width, 100f32);
34    assert_eq!(sprawl.layout(node).unwrap().size.height, 100f32);
35    assert_eq!(sprawl.layout(node).unwrap().location.x, 0f32);
36    assert_eq!(sprawl.layout(node).unwrap().location.y, 0f32);
37    assert_eq!(sprawl.layout(node0).unwrap().size.width, 100f32);
38    assert_eq!(sprawl.layout(node0).unwrap().size.height, 100f32);
39    assert_eq!(sprawl.layout(node0).unwrap().location.x, 0f32);
40    assert_eq!(sprawl.layout(node0).unwrap().location.y, 0f32);
41    assert_eq!(sprawl.layout(node1).unwrap().size.width, 0f32);
42    assert_eq!(sprawl.layout(node1).unwrap().size.height, 0f32);
43    assert_eq!(sprawl.layout(node1).unwrap().location.x, 0f32);
44    assert_eq!(sprawl.layout(node1).unwrap().location.y, 0f32);
45}