gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 499HTML 254C 19JavaScript 81378 Definitions

⎇ 06471455e8cc93ab7ffee650a033ae7df8943611 tests/generated/flex_basis_smaller_than_content_row.rs Rust · 52 lines · 2.0 KB History Who touched what raw

rename stretch to stretch2 99945cfc7 · elbaro ·

1#[test]
2fn flex_basis_smaller_than_content_row() {
3    let mut stretch = stretch2::Stretch::new();
4    let node00 = stretch
5        .new_node(
6            stretch2::style::Style {
7                size: stretch2::geometry::Size {
8                    width: stretch2::style::Dimension::Points(100f32),
9                    height: stretch2::style::Dimension::Points(100f32),
10                    ..Default::default()
11                },
12                ..Default::default()
13            },
14            &[],
15        )
16        .unwrap();
17    let node0 = stretch
18        .new_node(
19            stretch2::style::Style {
20                flex_direction: stretch2::style::FlexDirection::Column,
21                flex_basis: stretch2::style::Dimension::Points(50f32),
22                ..Default::default()
23            },
24            &[node00],
25        )
26        .unwrap();
27    let node = stretch
28        .new_node(
29            stretch2::style::Style {
30                size: stretch2::geometry::Size {
31                    width: stretch2::style::Dimension::Points(100f32),
32                    ..Default::default()
33                },
34                ..Default::default()
35            },
36            &[node0],
37        )
38        .unwrap();
39    stretch.compute_layout(node, stretch2::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, 100f32);
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, 100f32);
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}