⎇ 477ff4aff498cbae4cdfbf0cda1ee5b04c784f08
tests/generated/flex/wrap_child.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn wrap_child() {
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 {
9 width: taffy::style::Dimension::Length(100f32),
10 height: taffy::style::Dimension::Length(100f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node = taffy
16 .new_with_children(
17 taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
18 &[node0],
19 )
20 .unwrap();
21 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
22 println!("\nComputed tree:");
23 taffy.print_tree(node);
24 println!();
25 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
26 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
27 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
28 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
29 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
30 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
31 #[cfg(feature = "content_size")]
32 assert_eq!(
33 layout.scroll_width(),
34 0f32,
35 "scroll_width of node {:?}. Expected {}. Actual {}",
36 node,
37 0f32,
38 layout.scroll_width()
39 );
40 #[cfg(feature = "content_size")]
41 assert_eq!(
42 layout.scroll_height(),
43 0f32,
44 "scroll_height of node {:?}. Expected {}. Actual {}",
45 node,
46 0f32,
47 layout.scroll_height()
48 );
49 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
50 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
51 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
52 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
53 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
55 #[cfg(feature = "content_size")]
56 assert_eq!(
57 layout.scroll_width(),
58 0f32,
59 "scroll_width of node {:?}. Expected {}. Actual {}",
60 node0,
61 0f32,
62 layout.scroll_width()
63 );
64 #[cfg(feature = "content_size")]
65 assert_eq!(
66 layout.scroll_height(),
67 0f32,
68 "scroll_height of node {:?}. Expected {}. Actual {}",
69 node0,
70 0f32,
71 layout.scroll_height()
72 );
73}