tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 695HTML 648Markdown 12TOML 62320 Definiciones

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/margin_auto_mutiple_children_column.rs Rust · 77 líneas · 3.2 KB Historia Quién tocó qué crudo

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

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