tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definitions

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

Fix formatting d67e82255 · elbaro ·

1#[test]
2fn flex_direction_row_reverse() {
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                flex_direction: stretch2::style::FlexDirection::RowReverse,
44                size: stretch2::geometry::Size {
45                    width: stretch2::style::Dimension::Points(100f32),
46                    height: stretch2::style::Dimension::Points(100f32),
47                    ..Default::default()
48                },
49                ..Default::default()
50            },
51            &[node0, node1, node2],
52        )
53        .unwrap();
54    stretch.compute_layout(node, stretch2::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, 10f32);
60    assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
61    assert_eq!(stretch.layout(node0).unwrap().location.x, 90f32);
62    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
63    assert_eq!(stretch.layout(node1).unwrap().size.width, 10f32);
64    assert_eq!(stretch.layout(node1).unwrap().size.height, 100f32);
65    assert_eq!(stretch.layout(node1).unwrap().location.x, 80f32);
66    assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
67    assert_eq!(stretch.layout(node2).unwrap().size.width, 10f32);
68    assert_eq!(stretch.layout(node2).unwrap().size.height, 100f32);
69    assert_eq!(stretch.layout(node2).unwrap().location.x, 70f32);
70    assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
71}