tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1111HTML 1039Markdown 12TOML 94541 Definiciones

⎇ 7e05de8652da047a4d2a567bc03302e70d633c2c tests/generated/max_width.rs Rust · 38 líneas · 1.4 KB Historia Quién tocó qué crudo

update tests and benchmarks to use new api 1f8c44154 · Emil Sjölander ·

1#[test]
2fn max_width() {
3    let layout = stretch::node::Node::new(
4        stretch::style::Style {
5            flex_direction: stretch::style::FlexDirection::Column,
6            size: stretch::geometry::Size {
7                width: stretch::style::Dimension::Points(100f32),
8                height: stretch::style::Dimension::Points(100f32),
9                ..Default::default()
10            },
11            ..Default::default()
12        },
13        vec![&stretch::node::Node::new(
14            stretch::style::Style {
15                size: stretch::geometry::Size {
16                    height: stretch::style::Dimension::Points(10f32),
17                    ..Default::default()
18                },
19                max_size: stretch::geometry::Size {
20                    width: stretch::style::Dimension::Points(50f32),
21                    ..Default::default()
22                },
23                ..Default::default()
24            },
25            vec![],
26        )],
27    )
28    .compute_layout(stretch::geometry::Size::undefined())
29    .unwrap();
30    assert_eq!(layout.size.width, 100f32);
31    assert_eq!(layout.size.height, 100f32);
32    assert_eq!(layout.location.x, 0f32);
33    assert_eq!(layout.location.y, 0f32);
34    assert_eq!(layout.children[0usize].size.width, 50f32);
35    assert_eq!(layout.children[0usize].size.height, 10f32);
36    assert_eq!(layout.children[0usize].location.x, 0f32);
37    assert_eq!(layout.children[0usize].location.y, 0f32);
38}