gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 695HTML 648Markdown 12TOML 62320 Sutichaykuna

⎇ e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32 tests/generated/grid_align_items_baseline_child_multiline_override.rs Rust · 126 siq'ikuna · 6.8 KB Ñawpa willay Pi imata llamkarqan ch'uya

Update wrong css in test (#352) baf028789 · adjabaev ·

1#[test]
2fn grid_align_items_baseline_child_multiline_override() {
3    use slotmap::Key;
4    #[allow(unused_imports)]
5    use taffy::{layout::Layout, prelude::*};
6    let mut taffy = taffy::Taffy::new();
7    let node0 = taffy
8        .new_leaf(taffy::style::Style {
9            display: taffy::style::Display::Grid,
10            size: taffy::geometry::Size {
11                width: taffy::style::Dimension::Points(50f32),
12                height: taffy::style::Dimension::Points(60f32),
13            },
14            ..Default::default()
15        })
16        .unwrap();
17    let node10 = taffy
18        .new_leaf(taffy::style::Style {
19            display: taffy::style::Display::Grid,
20            size: taffy::geometry::Size {
21                width: taffy::style::Dimension::Points(25f32),
22                height: taffy::style::Dimension::Points(20f32),
23            },
24            ..Default::default()
25        })
26        .unwrap();
27    let node11 = taffy
28        .new_leaf(taffy::style::Style {
29            display: taffy::style::Display::Grid,
30            align_self: Some(taffy::style::AlignSelf::Baseline),
31            size: taffy::geometry::Size {
32                width: taffy::style::Dimension::Points(25f32),
33                height: taffy::style::Dimension::Points(10f32),
34            },
35            ..Default::default()
36        })
37        .unwrap();
38    let node12 = taffy
39        .new_leaf(taffy::style::Style {
40            display: taffy::style::Display::Grid,
41            size: taffy::geometry::Size {
42                width: taffy::style::Dimension::Points(25f32),
43                height: taffy::style::Dimension::Points(20f32),
44            },
45            ..Default::default()
46        })
47        .unwrap();
48    let node13 = taffy
49        .new_leaf(taffy::style::Style {
50            display: taffy::style::Display::Grid,
51            align_self: Some(taffy::style::AlignSelf::Baseline),
52            size: taffy::geometry::Size {
53                width: taffy::style::Dimension::Points(25f32),
54                height: taffy::style::Dimension::Points(10f32),
55            },
56            ..Default::default()
57        })
58        .unwrap();
59    let node1 = taffy
60        .new_with_children(
61            taffy::style::Style {
62                display: taffy::style::Display::Grid,
63                grid_template_columns: vec![auto(), auto()],
64                size: taffy::geometry::Size {
65                    width: taffy::style::Dimension::Points(50f32),
66                    height: taffy::style::Dimension::Points(25f32),
67                },
68                ..Default::default()
69            },
70            &[node10, node11, node12, node13],
71        )
72        .unwrap();
73    let node = taffy
74        .new_with_children(
75            taffy::style::Style {
76                display: taffy::style::Display::Grid,
77                align_items: Some(taffy::style::AlignItems::Baseline),
78                size: taffy::geometry::Size {
79                    width: taffy::style::Dimension::Points(100f32),
80                    height: taffy::style::Dimension::Points(100f32),
81                },
82                ..Default::default()
83            },
84            &[node0, node1],
85        )
86        .unwrap();
87    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
88    println!("\nComputed tree:");
89    taffy::debug::print_tree(&taffy, node);
90    println!();
91    let Layout { size, location, .. } = taffy.layout(node).unwrap();
92    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
93    assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
94    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
95    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
96    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
97    assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width);
98    assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, size.height);
99    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
100    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
101    let Layout { size, location, .. } = taffy.layout(node1).unwrap();
102    assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.width);
103    assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
104    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
105    assert_eq!(location.y, 68f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 68f32, location.y);
106    let Layout { size, location, .. } = taffy.layout(node10).unwrap();
107    assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 25f32, size.width);
108    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 20f32, size.height);
109    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
110    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
111    let Layout { size, location, .. } = taffy.layout(node11).unwrap();
112    assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node11.data(), 25f32, size.width);
113    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node11.data(), 10f32, size.height);
114    assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node11.data(), 25f32, location.x);
115    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node11.data(), 0f32, location.y);
116    let Layout { size, location, .. } = taffy.layout(node12).unwrap();
117    assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node12.data(), 25f32, size.width);
118    assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node12.data(), 20f32, size.height);
119    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12.data(), 0f32, location.x);
120    assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node12.data(), 20f32, location.y);
121    let Layout { size, location, .. } = taffy.layout(node13).unwrap();
122    assert_eq!(size.width, 25f32, "width of node {:?}. Expected {}. Actual {}", node13.data(), 25f32, size.width);
123    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node13.data(), 10f32, size.height);
124    assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node13.data(), 25f32, location.x);
125    assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node13.data(), 20f32, location.y);
126}