tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 583HTML 275Markdown 8TOML 41586 Sutichaykuna

⎇ d67e82255da07928c7e415ea7364529d204bbaf9 tests/generated/flex_basis_overrides_main_size.rs Rust · 74 siq'ikuna · 2.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

Fix formatting d67e82255 · elbaro ·

1#[test]
2fn flex_basis_overrides_main_size() {
3    let mut stretch = stretch2::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch2::style::Style {
7                flex_grow: 1f32,
8                flex_basis: stretch2::style::Dimension::Points(50f32),
9                size: stretch2::geometry::Size {
10                    width: stretch2::style::Dimension::Points(20f32),
11                    ..Default::default()
12                },
13                ..Default::default()
14            },
15            &[],
16        )
17        .unwrap();
18    let node1 = stretch
19        .new_node(
20            stretch2::style::Style {
21                flex_grow: 1f32,
22                size: stretch2::geometry::Size {
23                    width: stretch2::style::Dimension::Points(10f32),
24                    ..Default::default()
25                },
26                ..Default::default()
27            },
28            &[],
29        )
30        .unwrap();
31    let node2 = stretch
32        .new_node(
33            stretch2::style::Style {
34                flex_grow: 1f32,
35                size: stretch2::geometry::Size {
36                    width: stretch2::style::Dimension::Points(10f32),
37                    ..Default::default()
38                },
39                ..Default::default()
40            },
41            &[],
42        )
43        .unwrap();
44    let node = stretch
45        .new_node(
46            stretch2::style::Style {
47                size: stretch2::geometry::Size {
48                    width: stretch2::style::Dimension::Points(100f32),
49                    height: stretch2::style::Dimension::Points(100f32),
50                    ..Default::default()
51                },
52                ..Default::default()
53            },
54            &[node0, node1, node2],
55        )
56        .unwrap();
57    stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
58    assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
59    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
60    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
61    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
62    assert_eq!(stretch.layout(node0).unwrap().size.width, 60f32);
63    assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
64    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
65    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
66    assert_eq!(stretch.layout(node1).unwrap().size.width, 20f32);
67    assert_eq!(stretch.layout(node1).unwrap().size.height, 100f32);
68    assert_eq!(stretch.layout(node1).unwrap().location.x, 60f32);
69    assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
70    assert_eq!(stretch.layout(node2).unwrap().size.width, 20f32);
71    assert_eq!(stretch.layout(node2).unwrap().size.height, 100f32);
72    assert_eq!(stretch.layout(node2).unwrap().location.x, 80f32);
73    assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
74}