gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Definiciones

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/flex_grow_less_than_factor_one.rs Rust · 50 líneas · 2.0 KB Historia Quién tocó qué crudo

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

1#[test]
2fn flex_grow_less_than_factor_one() {
3    let layout = stretch::node::Node::new(
4        stretch::style::Style {
5            size: stretch::geometry::Size {
6                width: stretch::style::Dimension::Points(500f32),
7                height: stretch::style::Dimension::Points(200f32),
8                ..Default::default()
9            },
10            ..Default::default()
11        },
12        vec![
13            &stretch::node::Node::new(
14                stretch::style::Style {
15                    flex_grow: 0.2f32,
16                    flex_shrink: 0f32,
17                    flex_basis: stretch::style::Dimension::Points(40f32),
18                    ..Default::default()
19                },
20                vec![],
21            ),
22            &stretch::node::Node::new(
23                stretch::style::Style { flex_grow: 0.2f32, flex_shrink: 0f32, ..Default::default() },
24                vec![],
25            ),
26            &stretch::node::Node::new(
27                stretch::style::Style { flex_grow: 0.4f32, flex_shrink: 0f32, ..Default::default() },
28                vec![],
29            ),
30        ],
31    )
32    .compute_layout(stretch::geometry::Size::undefined())
33    .unwrap();
34    assert_eq!(layout.size.width, 500f32);
35    assert_eq!(layout.size.height, 200f32);
36    assert_eq!(layout.location.x, 0f32);
37    assert_eq!(layout.location.y, 0f32);
38    assert_eq!(layout.children[0usize].size.width, 132f32);
39    assert_eq!(layout.children[0usize].size.height, 200f32);
40    assert_eq!(layout.children[0usize].location.x, 0f32);
41    assert_eq!(layout.children[0usize].location.y, 0f32);
42    assert_eq!(layout.children[1usize].size.width, 92f32);
43    assert_eq!(layout.children[1usize].size.height, 200f32);
44    assert_eq!(layout.children[1usize].location.x, 132f32);
45    assert_eq!(layout.children[1usize].location.y, 0f32);
46    assert_eq!(layout.children[2usize].size.width, 184f32);
47    assert_eq!(layout.children[2usize].size.height, 200f32);
48    assert_eq!(layout.children[2usize].location.x, 224f32);
49    assert_eq!(layout.children[2usize].location.y, 0f32);
50}