tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 238Markdown 7TOML 41214 Definitions

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/relative_position_should_not_nudge_siblings.rs Rust · 63 lines · 2.5 KB History Who touched what raw

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

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