tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definitions

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/justify_content_row_max_width_and_margin.rs Rust · 47 lines · 1.9 KB History Who touched what raw

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

1#[test]
2fn justify_content_row_max_width_and_margin() {
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(20f32),
9                    height: stretch::style::Dimension::Points(20f32),
10                    ..Default::default()
11                },
12                margin: stretch::geometry::Rect {
13                    start: stretch::style::Dimension::Points(100f32),
14                    ..Default::default()
15                },
16                ..Default::default()
17            },
18            vec![],
19        )
20        .unwrap();
21    let node = stretch
22        .new_node(
23            stretch::style::Style {
24                justify_content: stretch::style::JustifyContent::Center,
25                size: stretch::geometry::Size {
26                    width: stretch::style::Dimension::Points(100f32),
27                    ..Default::default()
28                },
29                max_size: stretch::geometry::Size {
30                    width: stretch::style::Dimension::Points(80f32),
31                    ..Default::default()
32                },
33                ..Default::default()
34            },
35            vec![node0],
36        )
37        .unwrap();
38    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
39    assert_eq!(stretch.layout(node).unwrap().size.width, 80f32);
40    assert_eq!(stretch.layout(node).unwrap().size.height, 20f32);
41    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
42    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
43    assert_eq!(stretch.layout(node0).unwrap().size.width, 0f32);
44    assert_eq!(stretch.layout(node0).unwrap().size.height, 20f32);
45    assert_eq!(stretch.layout(node0).unwrap().location.x, 90f32);
46    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
47}