gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 492HTML 245JavaScript 8CSS 61138 Definiciones

⎇ 48e4800f14c6af5cd26275fb570d11b93e279654 tests/generated/flex/align_baseline_multiline_column2.rs Rust · 126 líneas · 6.6 KB Historia Quién tocó qué crudo

Sort test fixtures and generated tests into folders (#514) 24b8faf43 · aemreaydin ·

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