tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 31442 Definitions

⎇ d67e82255da07928c7e415ea7364529d204bbaf9 tests/generated/flex_direction_row_no_width.rs Rust · 69 lines · 2.6 KB History Who touched what raw

Fix formatting d67e82255 · elbaro ·

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