tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1076HTML 1008Markdown 12TOML 83208 Sutichaykuna

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/justify_content_min_max.rs Rust · 48 siq'ikuna · 1.9 KB Ñawpa willay Pi imata llamkarqan ch'uya

index: update tests to API changes 48c69198a · msiglreith ·

1#[test]
2fn justify_content_min_max() {
3    let mut stretch = stretch::Stretch::new();
4    let node0 = stretch
5        .new_node(
6            stretch::style::Style {
7                size: stretch::geometry::Size {
8                    width: stretch::style::Dimension::Points(60f32),
9                    height: stretch::style::Dimension::Points(60f32),
10                    ..Default::default()
11                },
12                ..Default::default()
13            },
14            vec![],
15        )
16        .unwrap();
17    let node = stretch
18        .new_node(
19            stretch::style::Style {
20                flex_direction: stretch::style::FlexDirection::Column,
21                justify_content: stretch::style::JustifyContent::Center,
22                size: stretch::geometry::Size {
23                    width: stretch::style::Dimension::Points(100f32),
24                    ..Default::default()
25                },
26                min_size: stretch::geometry::Size {
27                    height: stretch::style::Dimension::Points(100f32),
28                    ..Default::default()
29                },
30                max_size: stretch::geometry::Size {
31                    height: stretch::style::Dimension::Points(200f32),
32                    ..Default::default()
33                },
34                ..Default::default()
35            },
36            vec![node0],
37        )
38        .unwrap();
39    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
40    assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
41    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
42    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
43    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
44    assert_eq!(stretch.layout(node0).unwrap().size.width, 60f32);
45    assert_eq!(stretch.layout(node0).unwrap().size.height, 60f32);
46    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
47    assert_eq!(stretch.layout(node0).unwrap().location.y, 20f32);
48}