gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81414 Definiciones

⎇ 0.1.x tests/generated/wrap_reverse_column.rs Rust · 92 líneas · 3.6 KB Historia Quién tocó qué crudo

Rename sprawl to taffy (#134) 8936790d6 · Alice Cecile ·

1#[test]
2fn wrap_reverse_column() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_node(
6            taffy::style::Style {
7                size: taffy::geometry::Size {
8                    width: taffy::style::Dimension::Points(30f32),
9                    height: taffy::style::Dimension::Points(31f32),
10                    ..Default::default()
11                },
12                ..Default::default()
13            },
14            &[],
15        )
16        .unwrap();
17    let node1 = taffy
18        .new_node(
19            taffy::style::Style {
20                size: taffy::geometry::Size {
21                    width: taffy::style::Dimension::Points(30f32),
22                    height: taffy::style::Dimension::Points(32f32),
23                    ..Default::default()
24                },
25                ..Default::default()
26            },
27            &[],
28        )
29        .unwrap();
30    let node2 = taffy
31        .new_node(
32            taffy::style::Style {
33                size: taffy::geometry::Size {
34                    width: taffy::style::Dimension::Points(30f32),
35                    height: taffy::style::Dimension::Points(33f32),
36                    ..Default::default()
37                },
38                ..Default::default()
39            },
40            &[],
41        )
42        .unwrap();
43    let node3 = taffy
44        .new_node(
45            taffy::style::Style {
46                size: taffy::geometry::Size {
47                    width: taffy::style::Dimension::Points(30f32),
48                    height: taffy::style::Dimension::Points(34f32),
49                    ..Default::default()
50                },
51                ..Default::default()
52            },
53            &[],
54        )
55        .unwrap();
56    let node = taffy
57        .new_node(
58            taffy::style::Style {
59                flex_direction: taffy::style::FlexDirection::Column,
60                flex_wrap: taffy::style::FlexWrap::WrapReverse,
61                size: taffy::geometry::Size {
62                    width: taffy::style::Dimension::Points(100f32),
63                    height: taffy::style::Dimension::Points(100f32),
64                    ..Default::default()
65                },
66                ..Default::default()
67            },
68            &[node0, node1, node2, node3],
69        )
70        .unwrap();
71    taffy.compute_layout(node, taffy::geometry::Size::undefined()).unwrap();
72    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
73    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
74    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
75    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
76    assert_eq!(taffy.layout(node0).unwrap().size.width, 30f32);
77    assert_eq!(taffy.layout(node0).unwrap().size.height, 31f32);
78    assert_eq!(taffy.layout(node0).unwrap().location.x, 70f32);
79    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
80    assert_eq!(taffy.layout(node1).unwrap().size.width, 30f32);
81    assert_eq!(taffy.layout(node1).unwrap().size.height, 32f32);
82    assert_eq!(taffy.layout(node1).unwrap().location.x, 70f32);
83    assert_eq!(taffy.layout(node1).unwrap().location.y, 31f32);
84    assert_eq!(taffy.layout(node2).unwrap().size.width, 30f32);
85    assert_eq!(taffy.layout(node2).unwrap().size.height, 33f32);
86    assert_eq!(taffy.layout(node2).unwrap().location.x, 70f32);
87    assert_eq!(taffy.layout(node2).unwrap().location.y, 63f32);
88    assert_eq!(taffy.layout(node3).unwrap().size.width, 30f32);
89    assert_eq!(taffy.layout(node3).unwrap().size.height, 34f32);
90    assert_eq!(taffy.layout(node3).unwrap().location.x, 20f32);
91    assert_eq!(taffy.layout(node3).unwrap().location.y, 0f32);
92}