gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 498HTML 254C 19JavaScript 81349 Sutichaykuna

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/justify_content_overflow_min_max.rs Rust · 81 siq'ikuna · 3.3 KB Ñawpa willay Pi imata llamkarqan ch'uya

rename stretch to stretch2 99945cfc7 · elbaro ·

1#[test]
2fn justify_content_overflow_min_max() {
3    let mut stretch = stretch2::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch2::style::Style {
7                flex_shrink: 0f32,
8                size: stretch2::geometry::Size {
9                    width: stretch2::style::Dimension::Points(50f32),
10                    height: stretch2::style::Dimension::Points(50f32),
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_shrink: 0f32,
22                size: stretch2::geometry::Size {
23                    width: stretch2::style::Dimension::Points(50f32),
24                    height: stretch2::style::Dimension::Points(50f32),
25                    ..Default::default()
26                },
27                ..Default::default()
28            },
29            &[],
30        )
31        .unwrap();
32    let node2 = stretch
33        .new_node(
34            stretch2::style::Style {
35                flex_shrink: 0f32,
36                size: stretch2::geometry::Size {
37                    width: stretch2::style::Dimension::Points(50f32),
38                    height: stretch2::style::Dimension::Points(50f32),
39                    ..Default::default()
40                },
41                ..Default::default()
42            },
43            &[],
44        )
45        .unwrap();
46    let node = stretch
47        .new_node(
48            stretch2::style::Style {
49                flex_direction: stretch2::style::FlexDirection::Column,
50                justify_content: stretch2::style::JustifyContent::Center,
51                min_size: stretch2::geometry::Size {
52                    height: stretch2::style::Dimension::Points(100f32),
53                    ..Default::default()
54                },
55                max_size: stretch2::geometry::Size {
56                    height: stretch2::style::Dimension::Points(110f32),
57                    ..Default::default()
58                },
59                ..Default::default()
60            },
61            &[node0, node1, node2],
62        )
63        .unwrap();
64    stretch.compute_layout(node, stretch2::geometry::Size::undefined()).unwrap();
65    assert_eq!(stretch.layout(node).unwrap().size.width, 50f32);
66    assert_eq!(stretch.layout(node).unwrap().size.height, 110f32);
67    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
68    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
69    assert_eq!(stretch.layout(node0).unwrap().size.width, 50f32);
70    assert_eq!(stretch.layout(node0).unwrap().size.height, 50f32);
71    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
72    assert_eq!(stretch.layout(node0).unwrap().location.y, -20f32);
73    assert_eq!(stretch.layout(node1).unwrap().size.width, 50f32);
74    assert_eq!(stretch.layout(node1).unwrap().size.height, 50f32);
75    assert_eq!(stretch.layout(node1).unwrap().location.x, 0f32);
76    assert_eq!(stretch.layout(node1).unwrap().location.y, 30f32);
77    assert_eq!(stretch.layout(node2).unwrap().size.width, 50f32);
78    assert_eq!(stretch.layout(node2).unwrap().size.height, 50f32);
79    assert_eq!(stretch.layout(node2).unwrap().location.x, 0f32);
80    assert_eq!(stretch.layout(node2).unwrap().location.y, 80f32);
81}