⎇ e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32
tests/generated/align_content_space_between_single_line.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn align_content_space_between_single_line() {
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(10f32),
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(10f32),
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(10f32),
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(10f32),
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(10f32),
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(10f32),
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 align_content: Some(taffy::style::AlignContent::SpaceBetween),
65 size: taffy::geometry::Size {
66 width: taffy::style::Dimension::Points(100f32),
67 height: taffy::style::Dimension::Points(100f32),
68 },
69 ..Default::default()
70 },
71 &[node0, node1, node2, node3, node4, node5],
72 )
73 .unwrap();
74 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
75 println!("\nComputed tree:");
76 taffy::debug::print_tree(&taffy, node);
77 println!();
78 let Layout { size, location, .. } = taffy.layout(node).unwrap();
79 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
80 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
81 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
82 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
83 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
84 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.width);
85 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
88 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
89 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.width);
90 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.height);
91 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
93 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
94 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, size.width);
95 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, size.height);
96 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, location.x);
97 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
98 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
99 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 10f32, size.width);
100 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 10f32, size.height);
101 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 30f32, location.x);
102 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.y);
103 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
104 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 10f32, size.width);
105 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4.data(), 10f32, size.height);
106 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node4.data(), 40f32, location.x);
107 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4.data(), 0f32, location.y);
108 let Layout { size, location, .. } = taffy.layout(node5).unwrap();
109 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node5.data(), 10f32, size.width);
110 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node5.data(), 10f32, size.height);
111 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node5.data(), 50f32, location.x);
112 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5.data(), 0f32, location.y);
113}