gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1086HTML 1018Markdown 12TOML 84406 Definiciones

⎇ 54e00d63d6d4a99e89ac0934a6bb61e415ab1006 tests/generated/justify_content_row_space_around.rs Rust · 64 líneas · 2.5 KB Historia Quién tocó qué crudo

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

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