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