tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definitions

⎇ a149c6b6b8f7d25328e78ba649b76d1841c55d9d tests/generated/justify_content_column_space_evenly.rs Rust · 72 lines · 2.8 KB History Who touched what raw

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

1#[test]
2fn justify_content_column_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                flex_direction: stretch::style::FlexDirection::Column,
44                justify_content: stretch::style::JustifyContent::SpaceEvenly,
45                size: stretch::geometry::Size {
46                    width: stretch::style::Dimension::Points(100f32),
47                    height: stretch::style::Dimension::Points(100f32),
48                    ..Default::default()
49                },
50                ..Default::default()
51            },
52            vec![node0, node1, node2],
53        )
54        .unwrap();
55    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
56    assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
57    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
58    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
59    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
60    assert_eq!(stretch.layout(node0).unwrap().size.width, 100f32);
61    assert_eq!(stretch.layout(node0).unwrap().size.height, 10f32);
62    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
63    assert_eq!(stretch.layout(node0).unwrap().location.y, 18f32);
64    assert_eq!(stretch.layout(node1).unwrap().size.width, 100f32);
65    assert_eq!(stretch.layout(node1).unwrap().size.height, 10f32);
66    assert_eq!(stretch.layout(node1).unwrap().location.x, 0f32);
67    assert_eq!(stretch.layout(node1).unwrap().location.y, 45f32);
68    assert_eq!(stretch.layout(node2).unwrap().size.width, 100f32);
69    assert_eq!(stretch.layout(node2).unwrap().size.height, 10f32);
70    assert_eq!(stretch.layout(node2).unwrap().location.x, 0f32);
71    assert_eq!(stretch.layout(node2).unwrap().location.y, 73f32);
72}