⎇ 837d03fde9d8a4efa0f4eaf1e8be2fd34a719a50
tests/generated/align_items_center_min_max_with_padding.rs
History
Who touched what
raw
1#[test]
2fn align_items_center_min_max_with_padding() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(62f32),
11 height: taffy::style::Dimension::Points(62f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node = taffy
17 .new_with_children(
18 taffy::style::Style {
19 align_items: Some(taffy::style::AlignItems::Center),
20 min_size: taffy::geometry::Size {
21 width: taffy::style::Dimension::Points(320f32),
22 height: taffy::style::Dimension::Points(72f32),
23 },
24 max_size: taffy::geometry::Size {
25 width: taffy::style::Dimension::Points(320f32),
26 height: taffy::style::Dimension::Points(504f32),
27 },
28 padding: taffy::geometry::Rect {
29 left: zero(),
30 right: zero(),
31 top: taffy::style::LengthPercentage::Points(8f32),
32 bottom: taffy::style::LengthPercentage::Points(8f32),
33 },
34 ..Default::default()
35 },
36 &[node0],
37 )
38 .unwrap();
39 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
40 println!("\nComputed tree:");
41 taffy::debug::print_tree(&taffy, node);
42 println!();
43 let Layout { size, location, .. } = taffy.layout(node).unwrap();
44 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
45 assert_eq!(size.height, 78f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 78f32, size.height);
46 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
47 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
48 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
49 assert_eq!(size.width, 62f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 62f32, size.width);
50 assert_eq!(size.height, 62f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 62f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
52 assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
53}