gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Sutichaykuna

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/rounding_fractial_input_1.rs Rust · 68 siq'ikuna · 2.7 KB Ñawpa willay Pi imata llamkarqan ch'uya

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

1#[test]
2fn rounding_fractial_input_1() {
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(113.4f32),
9                ..Default::default()
10            },
11            ..Default::default()
12        },
13        vec![
14            &stretch::node::Node::new(
15                stretch::style::Style {
16                    flex_grow: 1f32,
17                    flex_basis: stretch::style::Dimension::Points(50f32),
18                    size: stretch::geometry::Size {
19                        height: stretch::style::Dimension::Points(20f32),
20                        ..Default::default()
21                    },
22                    ..Default::default()
23                },
24                vec![],
25            ),
26            &stretch::node::Node::new(
27                stretch::style::Style {
28                    flex_grow: 1f32,
29                    size: stretch::geometry::Size {
30                        height: stretch::style::Dimension::Points(10f32),
31                        ..Default::default()
32                    },
33                    ..Default::default()
34                },
35                vec![],
36            ),
37            &stretch::node::Node::new(
38                stretch::style::Style {
39                    flex_grow: 1f32,
40                    size: stretch::geometry::Size {
41                        height: stretch::style::Dimension::Points(10f32),
42                        ..Default::default()
43                    },
44                    ..Default::default()
45                },
46                vec![],
47            ),
48        ],
49    )
50    .compute_layout(stretch::geometry::Size::undefined())
51    .unwrap();
52    assert_eq!(layout.size.width, 100f32);
53    assert_eq!(layout.size.height, 113f32);
54    assert_eq!(layout.location.x, 0f32);
55    assert_eq!(layout.location.y, 0f32);
56    assert_eq!(layout.children[0usize].size.width, 100f32);
57    assert_eq!(layout.children[0usize].size.height, 64f32);
58    assert_eq!(layout.children[0usize].location.x, 0f32);
59    assert_eq!(layout.children[0usize].location.y, 0f32);
60    assert_eq!(layout.children[1usize].size.width, 100f32);
61    assert_eq!(layout.children[1usize].size.height, 25f32);
62    assert_eq!(layout.children[1usize].location.x, 0f32);
63    assert_eq!(layout.children[1usize].location.y, 64f32);
64    assert_eq!(layout.children[2usize].size.width, 100f32);
65    assert_eq!(layout.children[2usize].size.height, 24f32);
66    assert_eq!(layout.children[2usize].location.x, 0f32);
67    assert_eq!(layout.children[2usize].location.y, 89f32);
68}