⎇ c154b8aa719da0d6f8636b123765a47fa40a3306
tests/generated/block/block_align_baseline_child_top.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn block_align_baseline_child_top() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 display: taffy::style::Display::Block,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(50f32),
11 height: taffy::style::Dimension::Length(50f32),
12 },
13 inset: taffy::geometry::Rect {
14 left: auto(),
15 right: auto(),
16 top: taffy::style::LengthPercentageAuto::Length(10f32),
17 bottom: auto(),
18 },
19 ..Default::default()
20 })
21 .unwrap();
22 let node10 = taffy
23 .new_leaf(taffy::style::Style {
24 display: taffy::style::Display::Block,
25 size: taffy::geometry::Size {
26 width: taffy::style::Dimension::Length(50f32),
27 height: taffy::style::Dimension::Length(10f32),
28 },
29 ..Default::default()
30 })
31 .unwrap();
32 let node1 = taffy
33 .new_with_children(
34 taffy::style::Style {
35 display: taffy::style::Display::Block,
36 size: taffy::geometry::Size {
37 width: taffy::style::Dimension::Length(50f32),
38 height: taffy::style::Dimension::Length(20f32),
39 },
40 ..Default::default()
41 },
42 &[node10],
43 )
44 .unwrap();
45 let node = taffy
46 .new_with_children(
47 taffy::style::Style {
48 align_items: Some(taffy::style::AlignItems::Baseline),
49 size: taffy::geometry::Size {
50 width: taffy::style::Dimension::Length(100f32),
51 height: taffy::style::Dimension::Length(100f32),
52 },
53 ..Default::default()
54 },
55 &[node0, node1],
56 )
57 .unwrap();
58 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
59 println!("\nComputed tree:");
60 taffy.print_tree(node);
61 println!();
62 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
63 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
64 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
65 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
67 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
68 #[cfg(feature = "content_size")]
69 assert_eq!(
70 layout.scroll_width(),
71 0f32,
72 "scroll_width of node {:?}. Expected {}. Actual {}",
73 node,
74 0f32,
75 layout.scroll_width()
76 );
77 #[cfg(feature = "content_size")]
78 assert_eq!(
79 layout.scroll_height(),
80 0f32,
81 "scroll_height of node {:?}. Expected {}. Actual {}",
82 node,
83 0f32,
84 layout.scroll_height()
85 );
86 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
87 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
88 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
89 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
90 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
91 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node0, 10f32, location.y);
92 #[cfg(feature = "content_size")]
93 assert_eq!(
94 layout.scroll_width(),
95 0f32,
96 "scroll_width of node {:?}. Expected {}. Actual {}",
97 node0,
98 0f32,
99 layout.scroll_width()
100 );
101 #[cfg(feature = "content_size")]
102 assert_eq!(
103 layout.scroll_height(),
104 0f32,
105 "scroll_height of node {:?}. Expected {}. Actual {}",
106 node0,
107 0f32,
108 layout.scroll_height()
109 );
110 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
111 let layout @ Layout { size, location, .. } = taffy.layout(node1).unwrap();
112 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
113 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
114 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
115 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
116 #[cfg(feature = "content_size")]
117 assert_eq!(
118 layout.scroll_width(),
119 0f32,
120 "scroll_width of node {:?}. Expected {}. Actual {}",
121 node1,
122 0f32,
123 layout.scroll_width()
124 );
125 #[cfg(feature = "content_size")]
126 assert_eq!(
127 layout.scroll_height(),
128 0f32,
129 "scroll_height of node {:?}. Expected {}. Actual {}",
130 node1,
131 0f32,
132 layout.scroll_height()
133 );
134 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
135 let layout @ Layout { size, location, .. } = taffy.layout(node10).unwrap();
136 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node10, 50f32, size.width);
137 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10, 10f32, size.height);
138 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
139 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
140 #[cfg(feature = "content_size")]
141 assert_eq!(
142 layout.scroll_width(),
143 0f32,
144 "scroll_width of node {:?}. Expected {}. Actual {}",
145 node10,
146 0f32,
147 layout.scroll_width()
148 );
149 #[cfg(feature = "content_size")]
150 assert_eq!(
151 layout.scroll_height(),
152 0f32,
153 "scroll_height of node {:?}. Expected {}. Actual {}",
154 node10,
155 0f32,
156 layout.scroll_height()
157 );
158}