gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 701HTML 654Markdown 12TOML 62332 Definiciones

⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089 tests/generated/flex/gap_row_gap_align_items_end.rs Rust · 232 líneas · 9.5 KB Historia Quién tocó qué crudo

Rename Taffy struct to TaffyTree (#580) 17235ffa2 · Nico Burns ·

1#[test]
2fn gap_row_gap_align_items_end() {
3    #[allow(unused_imports)]
4    use taffy::{prelude::*, tree::Layout, TaffyTree};
5    let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6    let node0 = taffy
7        .new_leaf(taffy::style::Style {
8            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
9            ..Default::default()
10        })
11        .unwrap();
12    let node1 = taffy
13        .new_leaf(taffy::style::Style {
14            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
15            ..Default::default()
16        })
17        .unwrap();
18    let node2 = taffy
19        .new_leaf(taffy::style::Style {
20            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
21            ..Default::default()
22        })
23        .unwrap();
24    let node3 = taffy
25        .new_leaf(taffy::style::Style {
26            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
27            ..Default::default()
28        })
29        .unwrap();
30    let node4 = taffy
31        .new_leaf(taffy::style::Style {
32            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
33            ..Default::default()
34        })
35        .unwrap();
36    let node5 = taffy
37        .new_leaf(taffy::style::Style {
38            size: taffy::geometry::Size { width: taffy::style::Dimension::Length(20f32), height: auto() },
39            ..Default::default()
40        })
41        .unwrap();
42    let node = taffy
43        .new_with_children(
44            taffy::style::Style {
45                flex_wrap: taffy::style::FlexWrap::Wrap,
46                align_items: Some(taffy::style::AlignItems::FlexEnd),
47                gap: taffy::geometry::Size {
48                    width: taffy::style::LengthPercentage::Length(10f32),
49                    height: taffy::style::LengthPercentage::Length(20f32),
50                },
51                size: taffy::geometry::Size {
52                    width: taffy::style::Dimension::Length(100f32),
53                    height: taffy::style::Dimension::Length(200f32),
54                },
55                ..Default::default()
56            },
57            &[node0, node1, node2, node3, node4, node5],
58        )
59        .unwrap();
60    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
61    println!("\nComputed tree:");
62    taffy.print_tree(node);
63    println!();
64    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
65    let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
66    assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
67    assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
68    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
69    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
70    #[cfg(feature = "content_size")]
71    assert_eq!(
72        layout.scroll_width(),
73        0f32,
74        "scroll_width of node {:?}. Expected {}. Actual {}",
75        node,
76        0f32,
77        layout.scroll_width()
78    );
79    #[cfg(feature = "content_size")]
80    assert_eq!(
81        layout.scroll_height(),
82        0f32,
83        "scroll_height of node {:?}. Expected {}. Actual {}",
84        node,
85        0f32,
86        layout.scroll_height()
87    );
88    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
89    let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
90    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
91    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
92    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
93    assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0, 90f32, location.y);
94    #[cfg(feature = "content_size")]
95    assert_eq!(
96        layout.scroll_width(),
97        0f32,
98        "scroll_width of node {:?}. Expected {}. Actual {}",
99        node0,
100        0f32,
101        layout.scroll_width()
102    );
103    #[cfg(feature = "content_size")]
104    assert_eq!(
105        layout.scroll_height(),
106        0f32,
107        "scroll_height of node {:?}. Expected {}. Actual {}",
108        node0,
109        0f32,
110        layout.scroll_height()
111    );
112    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
113    let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
114    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
115    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
116    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
117    assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1, 90f32, location.y);
118    #[cfg(feature = "content_size")]
119    assert_eq!(
120        layout.scroll_width(),
121        0f32,
122        "scroll_width of node {:?}. Expected {}. Actual {}",
123        node1,
124        0f32,
125        layout.scroll_width()
126    );
127    #[cfg(feature = "content_size")]
128    assert_eq!(
129        layout.scroll_height(),
130        0f32,
131        "scroll_height of node {:?}. Expected {}. Actual {}",
132        node1,
133        0f32,
134        layout.scroll_height()
135    );
136    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
137    let layout @ Layout { size, location, .. } = taffy.layout(node2).unwrap();
138    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
139    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height);
140    assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
141    assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2, 90f32, location.y);
142    #[cfg(feature = "content_size")]
143    assert_eq!(
144        layout.scroll_width(),
145        0f32,
146        "scroll_width of node {:?}. Expected {}. Actual {}",
147        node2,
148        0f32,
149        layout.scroll_width()
150    );
151    #[cfg(feature = "content_size")]
152    assert_eq!(
153        layout.scroll_height(),
154        0f32,
155        "scroll_height of node {:?}. Expected {}. Actual {}",
156        node2,
157        0f32,
158        layout.scroll_height()
159    );
160    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
161    let layout @ Layout { size, location, .. } = taffy.layout(node3).unwrap();
162    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
163    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height);
164    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
165    assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3, 200f32, location.y);
166    #[cfg(feature = "content_size")]
167    assert_eq!(
168        layout.scroll_width(),
169        0f32,
170        "scroll_width of node {:?}. Expected {}. Actual {}",
171        node3,
172        0f32,
173        layout.scroll_width()
174    );
175    #[cfg(feature = "content_size")]
176    assert_eq!(
177        layout.scroll_height(),
178        0f32,
179        "scroll_height of node {:?}. Expected {}. Actual {}",
180        node3,
181        0f32,
182        layout.scroll_height()
183    );
184    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
185    let layout @ Layout { size, location, .. } = taffy.layout(node4).unwrap();
186    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
187    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height);
188    assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
189    assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4, 200f32, location.y);
190    #[cfg(feature = "content_size")]
191    assert_eq!(
192        layout.scroll_width(),
193        0f32,
194        "scroll_width of node {:?}. Expected {}. Actual {}",
195        node4,
196        0f32,
197        layout.scroll_width()
198    );
199    #[cfg(feature = "content_size")]
200    assert_eq!(
201        layout.scroll_height(),
202        0f32,
203        "scroll_height of node {:?}. Expected {}. Actual {}",
204        node4,
205        0f32,
206        layout.scroll_height()
207    );
208    #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
209    let layout @ Layout { size, location, .. } = taffy.layout(node5).unwrap();
210    assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
211    assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height);
212    assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
213    assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5, 200f32, location.y);
214    #[cfg(feature = "content_size")]
215    assert_eq!(
216        layout.scroll_width(),
217        0f32,
218        "scroll_width of node {:?}. Expected {}. Actual {}",
219        node5,
220        0f32,
221        layout.scroll_width()
222    );
223    #[cfg(feature = "content_size")]
224    assert_eq!(
225        layout.scroll_height(),
226        0f32,
227        "scroll_height of node {:?}. Expected {}. Actual {}",
228        node5,
229        0f32,
230        layout.scroll_height()
231    );
232}