Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn padding_no_child() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node = taffy
7 .new_leaf(taffy::style::Style {
8 padding: taffy::geometry::Rect {
9 left: taffy::style::LengthPercentage::Length(10f32),
10 right: taffy::style::LengthPercentage::Length(10f32),
11 top: taffy::style::LengthPercentage::Length(10f32),
12 bottom: taffy::style::LengthPercentage::Length(10f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
18 println!("\nComputed tree:");
19 taffy.print_tree(node);
20 println!();
21 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
22 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
23 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
24 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
25 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
26 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
27 #[cfg(feature = "content_size")]
28 assert_eq!(
29 layout.scroll_width(),
30 0f32,
31 "scroll_width of node {:?}. Expected {}. Actual {}",
32 node,
33 0f32,
34 layout.scroll_width()
35 );
36 #[cfg(feature = "content_size")]
37 assert_eq!(
38 layout.scroll_height(),
39 0f32,
40 "scroll_height of node {:?}. Expected {}. Actual {}",
41 node,
42 0f32,
43 layout.scroll_height()
44 );
45}