⎇ 0.5.x
tests/generated/flex/justify_content_column_min_height_and_margin.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn justify_content_column_min_height_and_margin() {
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(20f32),
10 height: taffy::style::Dimension::Length(20f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node0 = taffy
16 .new_with_children(
17 taffy::style::Style {
18 flex_direction: taffy::style::FlexDirection::Column,
19 justify_content: Some(taffy::style::JustifyContent::Center),
20 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) },
21 margin: taffy::geometry::Rect {
22 left: zero(),
23 right: zero(),
24 top: taffy::style::LengthPercentageAuto::Length(100f32),
25 bottom: zero(),
26 },
27 ..Default::default()
28 },
29 &[node00],
30 )
31 .unwrap();
32 let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
33 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
34 println!("\nComputed tree:");
35 taffy.print_tree(node);
36 println!();
37 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
38 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
39 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
40 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node, 150f32, size.height);
41 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
42 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
43 #[cfg(feature = "content_size")]
44 assert_eq!(
45 layout.scroll_width(),
46 0f32,
47 "scroll_width of node {:?}. Expected {}. Actual {}",
48 node,
49 0f32,
50 layout.scroll_width()
51 );
52 #[cfg(feature = "content_size")]
53 assert_eq!(
54 layout.scroll_height(),
55 0f32,
56 "scroll_height of node {:?}. Expected {}. Actual {}",
57 node,
58 0f32,
59 layout.scroll_height()
60 );
61 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
62 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
63 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
64 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
66 assert_eq!(location.y, 100f32, "y of node {:?}. Expected {}. Actual {}", node0, 100f32, location.y);
67 #[cfg(feature = "content_size")]
68 assert_eq!(
69 layout.scroll_width(),
70 0f32,
71 "scroll_width of node {:?}. Expected {}. Actual {}",
72 node0,
73 0f32,
74 layout.scroll_width()
75 );
76 #[cfg(feature = "content_size")]
77 assert_eq!(
78 layout.scroll_height(),
79 0f32,
80 "scroll_height of node {:?}. Expected {}. Actual {}",
81 node0,
82 0f32,
83 layout.scroll_height()
84 );
85 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
86 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
87 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width);
88 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
89 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
90 assert_eq!(location.y, 15f32, "y of node {:?}. Expected {}. Actual {}", node00, 15f32, location.y);
91 #[cfg(feature = "content_size")]
92 assert_eq!(
93 layout.scroll_width(),
94 0f32,
95 "scroll_width of node {:?}. Expected {}. Actual {}",
96 node00,
97 0f32,
98 layout.scroll_width()
99 );
100 #[cfg(feature = "content_size")]
101 assert_eq!(
102 layout.scroll_height(),
103 0f32,
104 "scroll_height of node {:?}. Expected {}. Actual {}",
105 node00,
106 0f32,
107 layout.scroll_height()
108 );
109}