Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn grid_minmax_column_with_auto_fixed() {
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 node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node = taffy
9 .new_with_children(
10 taffy::style::Style {
11 display: taffy::style::Display::Grid,
12 grid_template_rows: vec![length(40f32)],
13 grid_template_columns: vec![minmax(length(20f32), length(40f32)), auto()],
14 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(60f32), height: auto() },
15 ..Default::default()
16 },
17 &[node0, node1],
18 )
19 .unwrap();
20 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
21 println!("\nComputed tree:");
22 taffy.print_tree(node);
23 println!();
24 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
25 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
26 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
27 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
28 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
29 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
30 #[cfg(feature = "content_size")]
31 assert_eq!(
32 layout.scroll_width(),
33 0f32,
34 "scroll_width of node {:?}. Expected {}. Actual {}",
35 node,
36 0f32,
37 layout.scroll_width()
38 );
39 #[cfg(feature = "content_size")]
40 assert_eq!(
41 layout.scroll_height(),
42 0f32,
43 "scroll_height of node {:?}. Expected {}. Actual {}",
44 node,
45 0f32,
46 layout.scroll_height()
47 );
48 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
49 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
50 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
51 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
52 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
53 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
54 #[cfg(feature = "content_size")]
55 assert_eq!(
56 layout.scroll_width(),
57 0f32,
58 "scroll_width of node {:?}. Expected {}. Actual {}",
59 node0,
60 0f32,
61 layout.scroll_width()
62 );
63 #[cfg(feature = "content_size")]
64 assert_eq!(
65 layout.scroll_height(),
66 0f32,
67 "scroll_height of node {:?}. Expected {}. Actual {}",
68 node0,
69 0f32,
70 layout.scroll_height()
71 );
72 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
73 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
74 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
75 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
76 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1, 40f32, location.x);
77 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
78 #[cfg(feature = "content_size")]
79 assert_eq!(
80 layout.scroll_width(),
81 0f32,
82 "scroll_width of node {:?}. Expected {}. Actual {}",
83 node1,
84 0f32,
85 layout.scroll_width()
86 );
87 #[cfg(feature = "content_size")]
88 assert_eq!(
89 layout.scroll_height(),
90 0f32,
91 "scroll_height of node {:?}. Expected {}. Actual {}",
92 node1,
93 0f32,
94 layout.scroll_height()
95 );
96}