gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 498HTML 254C 19JavaScript 81349 Definiciones

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/wrap_row.rs Rust · 90 líneas · 3.5 KB Historia Quién tocó qué crudo

rename stretch to stretch2 99945cfc7 · elbaro ·

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