⎇ c154b8aa719da0d6f8636b123765a47fa40a3306
tests/generated/block/block_absolute_child_with_max_height.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn block_absolute_child_with_max_height() {
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 display: taffy::style::Display::Block,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(100f32),
11 height: taffy::style::Dimension::Length(150f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 display: taffy::style::Display::Block,
20 position: taffy::style::Position::Absolute,
21 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(100f32) },
22 inset: taffy::geometry::Rect {
23 left: auto(),
24 right: auto(),
25 top: auto(),
26 bottom: taffy::style::LengthPercentageAuto::Length(20f32),
27 },
28 ..Default::default()
29 },
30 &[node00],
31 )
32 .unwrap();
33 let node = taffy
34 .new_with_children(
35 taffy::style::Style {
36 display: taffy::style::Display::Block,
37 size: taffy::geometry::Size {
38 width: taffy::style::Dimension::Length(100f32),
39 height: taffy::style::Dimension::Length(200f32),
40 },
41 ..Default::default()
42 },
43 &[node0],
44 )
45 .unwrap();
46 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
47 println!("\nComputed tree:");
48 taffy.print_tree(node);
49 println!();
50 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
51 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
52 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
53 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
54 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
55 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
56 #[cfg(feature = "content_size")]
57 assert_eq!(
58 layout.scroll_width(),
59 0f32,
60 "scroll_width of node {:?}. Expected {}. Actual {}",
61 node,
62 0f32,
63 layout.scroll_width()
64 );
65 #[cfg(feature = "content_size")]
66 assert_eq!(
67 layout.scroll_height(),
68 30f32,
69 "scroll_height of node {:?}. Expected {}. Actual {}",
70 node,
71 30f32,
72 layout.scroll_height()
73 );
74 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
75 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
76 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
77 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
78 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
79 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
80 #[cfg(feature = "content_size")]
81 assert_eq!(
82 layout.scroll_width(),
83 0f32,
84 "scroll_width of node {:?}. Expected {}. Actual {}",
85 node0,
86 0f32,
87 layout.scroll_width()
88 );
89 #[cfg(feature = "content_size")]
90 assert_eq!(
91 layout.scroll_height(),
92 50f32,
93 "scroll_height of node {:?}. Expected {}. Actual {}",
94 node0,
95 50f32,
96 layout.scroll_height()
97 );
98 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
99 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
100 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width);
101 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height);
102 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
103 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
104 #[cfg(feature = "content_size")]
105 assert_eq!(
106 layout.scroll_width(),
107 0f32,
108 "scroll_width of node {:?}. Expected {}. Actual {}",
109 node00,
110 0f32,
111 layout.scroll_width()
112 );
113 #[cfg(feature = "content_size")]
114 assert_eq!(
115 layout.scroll_height(),
116 0f32,
117 "scroll_height of node {:?}. Expected {}. Actual {}",
118 node00,
119 0f32,
120 layout.scroll_height()
121 );
122}