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