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