tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 695HTML 648Markdown 12TOML 62320 Definiciones

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/flex_basis_overrides_main_size.rs Rust · 65 líneas · 2.7 KB Historia Quién tocó qué crudo

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

1#[test]
2fn flex_basis_overrides_main_size() {
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(50f32),
9                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(20f32), ..Default::default() },
10                ..Default::default()
11            },
12            vec![],
13        )
14        .unwrap();
15    let node1 = stretch
16        .new_node(
17            stretch::style::Style {
18                flex_grow: 1f32,
19                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(10f32), ..Default::default() },
20                ..Default::default()
21            },
22            vec![],
23        )
24        .unwrap();
25    let node2 = stretch
26        .new_node(
27            stretch::style::Style {
28                flex_grow: 1f32,
29                size: stretch::geometry::Size { width: stretch::style::Dimension::Points(10f32), ..Default::default() },
30                ..Default::default()
31            },
32            vec![],
33        )
34        .unwrap();
35    let node = stretch
36        .new_node(
37            stretch::style::Style {
38                size: stretch::geometry::Size {
39                    width: stretch::style::Dimension::Points(100f32),
40                    height: stretch::style::Dimension::Points(100f32),
41                    ..Default::default()
42                },
43                ..Default::default()
44            },
45            vec![node0, node1, node2],
46        )
47        .unwrap();
48    stretch.compute_layout(node, stretch::geometry::Size::undefined()).unwrap();
49    assert_eq!(stretch.layout(node).unwrap().size.width, 100f32);
50    assert_eq!(stretch.layout(node).unwrap().size.height, 100f32);
51    assert_eq!(stretch.layout(node).unwrap().location.x, 0f32);
52    assert_eq!(stretch.layout(node).unwrap().location.y, 0f32);
53    assert_eq!(stretch.layout(node0).unwrap().size.width, 60f32);
54    assert_eq!(stretch.layout(node0).unwrap().size.height, 100f32);
55    assert_eq!(stretch.layout(node0).unwrap().location.x, 0f32);
56    assert_eq!(stretch.layout(node0).unwrap().location.y, 0f32);
57    assert_eq!(stretch.layout(node1).unwrap().size.width, 20f32);
58    assert_eq!(stretch.layout(node1).unwrap().size.height, 100f32);
59    assert_eq!(stretch.layout(node1).unwrap().location.x, 60f32);
60    assert_eq!(stretch.layout(node1).unwrap().location.y, 0f32);
61    assert_eq!(stretch.layout(node2).unwrap().size.width, 20f32);
62    assert_eq!(stretch.layout(node2).unwrap().size.height, 100f32);
63    assert_eq!(stretch.layout(node2).unwrap().location.x, 80f32);
64    assert_eq!(stretch.layout(node2).unwrap().location.y, 0f32);
65}