tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Definitions

⎇ 0.2.x tests/generated/align_items_stretch.rs Rust · 35 lines · 1.4 KB History Who touched what raw

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

1#[test]
2fn align_items_stretch() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), ..Default::default() },
8                ..Default::default()
9            },
10            &[],
11        )
12        .unwrap();
13    let node = taffy
14        .new_with_children(
15            taffy::style::Style {
16                size: taffy::geometry::Size {
17                    width: taffy::style::Dimension::Points(100f32),
18                    height: taffy::style::Dimension::Points(100f32),
19                    ..Default::default()
20                },
21                ..Default::default()
22            },
23            &[node0],
24        )
25        .unwrap();
26    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
27    assert_eq!(taffy.layout(node).unwrap().size.width, 100f32);
28    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
29    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
30    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
31    assert_eq!(taffy.layout(node0).unwrap().size.width, 10f32);
32    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
33    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
34    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
35}