tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5464Rust 87Markdown 12TOML 91903 Definitions

⎇ a149c6b6b8f7d25328e78ba649b76d1841c55d9d tests/generated/flex_basis_larger_than_content_row.rs Rust · 52 lines · 2.0 KB History Who touched what raw

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

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