gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81378 Definiciones

⎇ 568f643327ec6b4879df0087def7f4e66b6acafb tests/generated/border_stretch_child.rs Rust · 44 líneas · 2.2 KB Historia Quién tocó qué crudo

Rename `Points`/`points` to `Length`/`length` in many APIs (#459) 55abeaf2e · Simon Sapin ·

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