tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definiciones

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/flex_root_ignored.rs Rust · 60 líneas · 2.3 KB Historia Quién tocó qué crudo

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

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