tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1076HTML 1008Markdown 12TOML 83208 Definitions

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/justify_content_row_space_evenly.rs Rust · 71 lines · 2.8 KB History Who touched what raw

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

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