⎇ 0.3.x
tests/generated/min_height_with_nested_fixed_height.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Reinstate FlexStart and FlexEnd alignment variants (#336)
1#[test]
2fn min_height_with_nested_fixed_height() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Points(40f32),
11 height: taffy::style::Dimension::Points(40f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 flex_direction: taffy::style::FlexDirection::Column,
20 align_self: Some(taffy::style::AlignSelf::FlexStart),
21 flex_shrink: 0f32,
22 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(28f32) },
23 margin: taffy::geometry::Rect {
24 left: zero(),
25 right: zero(),
26 top: taffy::style::LengthPercentageAuto::Points(8f32),
27 bottom: taffy::style::LengthPercentageAuto::Points(9f32),
28 },
29 ..Default::default()
30 },
31 &[node00],
32 )
33 .unwrap();
34 let node = taffy
35 .new_with_children(
36 taffy::style::Style {
37 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(320f32), height: auto() },
38 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(44f32) },
39 padding: taffy::geometry::Rect {
40 left: taffy::style::LengthPercentage::Points(16f32),
41 right: taffy::style::LengthPercentage::Points(16f32),
42 top: zero(),
43 bottom: zero(),
44 },
45 ..Default::default()
46 },
47 &[node0],
48 )
49 .unwrap();
50 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
51 println!("\nComputed tree:");
52 taffy::debug::print_tree(&taffy, node);
53 println!();
54 let Layout { size, location, .. } = taffy.layout(node).unwrap();
55 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
56 assert_eq!(size.height, 57f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 57f32, size.height);
57 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
58 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
59 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
60 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width);
61 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height);
62 assert_eq!(location.x, 16f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 16f32, location.x);
63 assert_eq!(location.y, 8f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 8f32, location.y);
64 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
65 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, size.width);
66 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, size.height);
67 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
68 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
69}