tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 695HTML 648Markdown 12TOML 62320 Definitions

⎇ bce89b1006f36ce35abfaf1f1c2b3dd95f3dffd3 tests/generated/wrapped_row_within_align_items_flex_start.rs Rust · 68 lines · 2.8 KB History Who touched what raw

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

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