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