gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 229Rust 8TOML 3CSS 1310 Definitions

⎇ 0.2.x tests/generated/gap_column_gap_flexible_undefined_parent.rs Rust · 68 lines · 2.6 KB History Who touched what raw

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

1#[test]
2fn gap_column_gap_flexible_undefined_parent() {
3    let mut taffy = taffy::Taffy::new();
4    let node0 = taffy
5        .new_with_children(
6            taffy::style::Style {
7                flex_grow: 1f32,
8                flex_shrink: 1f32,
9                flex_basis: taffy::style::Dimension::Percent(0f32),
10                ..Default::default()
11            },
12            &[],
13        )
14        .unwrap();
15    let node1 = taffy
16        .new_with_children(
17            taffy::style::Style {
18                flex_grow: 1f32,
19                flex_shrink: 1f32,
20                flex_basis: taffy::style::Dimension::Percent(0f32),
21                ..Default::default()
22            },
23            &[],
24        )
25        .unwrap();
26    let node2 = taffy
27        .new_with_children(
28            taffy::style::Style {
29                flex_grow: 1f32,
30                flex_shrink: 1f32,
31                flex_basis: taffy::style::Dimension::Percent(0f32),
32                ..Default::default()
33            },
34            &[],
35        )
36        .unwrap();
37    let node = taffy
38        .new_with_children(
39            taffy::style::Style {
40                gap: taffy::geometry::Size {
41                    width: taffy::style::Dimension::Points(10f32),
42                    height: taffy::style::Dimension::Points(20f32),
43                    ..Default::default()
44                },
45                size: taffy::geometry::Size { height: taffy::style::Dimension::Points(100f32), ..Default::default() },
46                ..Default::default()
47            },
48            &[node0, node1, node2],
49        )
50        .unwrap();
51    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
52    assert_eq!(taffy.layout(node).unwrap().size.width, 20f32);
53    assert_eq!(taffy.layout(node).unwrap().size.height, 100f32);
54    assert_eq!(taffy.layout(node).unwrap().location.x, 0f32);
55    assert_eq!(taffy.layout(node).unwrap().location.y, 0f32);
56    assert_eq!(taffy.layout(node0).unwrap().size.width, 0f32);
57    assert_eq!(taffy.layout(node0).unwrap().size.height, 100f32);
58    assert_eq!(taffy.layout(node0).unwrap().location.x, 0f32);
59    assert_eq!(taffy.layout(node0).unwrap().location.y, 0f32);
60    assert_eq!(taffy.layout(node1).unwrap().size.width, 0f32);
61    assert_eq!(taffy.layout(node1).unwrap().size.height, 100f32);
62    assert_eq!(taffy.layout(node1).unwrap().location.x, 10f32);
63    assert_eq!(taffy.layout(node1).unwrap().location.y, 0f32);
64    assert_eq!(taffy.layout(node2).unwrap().size.width, 0f32);
65    assert_eq!(taffy.layout(node2).unwrap().size.height, 100f32);
66    assert_eq!(taffy.layout(node2).unwrap().location.x, 20f32);
67    assert_eq!(taffy.layout(node2).unwrap().location.y, 0f32);
68}