⎇ c154b8aa719da0d6f8636b123765a47fa40a3306
tests/generated/flex/wrap_grandchild.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn wrap_grandchild() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node00 = 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 node0 = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node00]).unwrap();
16 let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).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, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
24 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, 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 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
46 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
47 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
48 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
51 #[cfg(feature = "content_size")]
52 assert_eq!(
53 layout.scroll_width(),
54 0f32,
55 "scroll_width of node {:?}. Expected {}. Actual {}",
56 node0,
57 0f32,
58 layout.scroll_width()
59 );
60 #[cfg(feature = "content_size")]
61 assert_eq!(
62 layout.scroll_height(),
63 0f32,
64 "scroll_height of node {:?}. Expected {}. Actual {}",
65 node0,
66 0f32,
67 layout.scroll_height()
68 );
69 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
70 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
71 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width);
72 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node00, 100f32, size.height);
73 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
74 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
75 #[cfg(feature = "content_size")]
76 assert_eq!(
77 layout.scroll_width(),
78 0f32,
79 "scroll_width of node {:?}. Expected {}. Actual {}",
80 node00,
81 0f32,
82 layout.scroll_width()
83 );
84 #[cfg(feature = "content_size")]
85 assert_eq!(
86 layout.scroll_height(),
87 0f32,
88 "scroll_height of node {:?}. Expected {}. Actual {}",
89 node00,
90 0f32,
91 layout.scroll_height()
92 );
93}