⎇ 0.3.x
tests/generated/align_content_stretch_row_with_fixed_height.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
1#[test]
2fn align_content_stretch_row_with_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 node0 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 let node1 = taffy
14 .new_leaf(taffy::style::Style {
15 size: taffy::geometry::Size {
16 width: taffy::style::Dimension::Points(50f32),
17 height: taffy::style::Dimension::Points(60f32),
18 },
19 ..Default::default()
20 })
21 .unwrap();
22 let node2 = taffy
23 .new_leaf(taffy::style::Style {
24 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
25 ..Default::default()
26 })
27 .unwrap();
28 let node3 = taffy
29 .new_leaf(taffy::style::Style {
30 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
31 ..Default::default()
32 })
33 .unwrap();
34 let node4 = taffy
35 .new_leaf(taffy::style::Style {
36 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(50f32), height: auto() },
37 ..Default::default()
38 })
39 .unwrap();
40 let node = taffy
41 .new_with_children(
42 taffy::style::Style {
43 flex_wrap: taffy::style::FlexWrap::Wrap,
44 align_content: Some(taffy::style::AlignContent::Stretch),
45 size: taffy::geometry::Size {
46 width: taffy::style::Dimension::Points(150f32),
47 height: taffy::style::Dimension::Points(100f32),
48 },
49 ..Default::default()
50 },
51 &[node0, node1, node2, node3, node4],
52 )
53 .unwrap();
54 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
55 println!("\nComputed tree:");
56 taffy::debug::print_tree(&taffy, node);
57 println!();
58 let Layout { size, location, .. } = taffy.layout(node).unwrap();
59 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 150f32, size.width);
60 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
61 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
63 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
64 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 50f32, size.width);
65 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 80f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
67 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
68 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
69 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, size.width);
70 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 60f32, size.height);
71 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 50f32, location.x);
72 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
73 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
74 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 50f32, size.width);
75 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 80f32, size.height);
76 assert_eq!(location.x, 100f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 100f32, location.x);
77 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
78 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
79 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 50f32, size.width);
80 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 20f32, size.height);
81 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.x);
82 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 80f32, location.y);
83 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
84 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 50f32, size.width);
85 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4.data(), 20f32, size.height);
86 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node4.data(), 50f32, location.x);
87 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4.data(), 80f32, location.y);
88}