Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn leaf_with_content_and_padding_border() {
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_with_context(
8 taffy::style::Style {
9 padding: taffy::geometry::Rect {
10 left: taffy::style::LengthPercentage::Length(8f32),
11 right: taffy::style::LengthPercentage::Length(4f32),
12 top: taffy::style::LengthPercentage::Length(2f32),
13 bottom: taffy::style::LengthPercentage::Length(6f32),
14 },
15 border: taffy::geometry::Rect {
16 left: taffy::style::LengthPercentage::Length(7f32),
17 right: taffy::style::LengthPercentage::Length(3f32),
18 top: taffy::style::LengthPercentage::Length(1f32),
19 bottom: taffy::style::LengthPercentage::Length(5f32),
20 },
21 ..Default::default()
22 },
23 crate::TextMeasure {
24 text_content: "HHHH",
25 writing_mode: crate::WritingMode::Horizontal,
26 _aspect_ratio: None,
27 },
28 )
29 .unwrap();
30 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
31 println!("\nComputed tree:");
32 taffy.print_tree(node);
33 println!();
34 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
35 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
36 assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node, 62f32, size.width);
37 assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node, 24f32, size.height);
38 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
39 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
40 #[cfg(feature = "content_size")]
41 assert_eq!(
42 layout.scroll_width(),
43 0f32,
44 "scroll_width of node {:?}. Expected {}. Actual {}",
45 node,
46 0f32,
47 layout.scroll_width()
48 );
49 #[cfg(feature = "content_size")]
50 assert_eq!(
51 layout.scroll_height(),
52 0f32,
53 "scroll_height of node {:?}. Expected {}. Actual {}",
54 node,
55 0f32,
56 layout.scroll_height()
57 );
58}