⎇ ae87fd0283feff32a5ceffe4c77394ff6ca88d39
tests/generated/gap_row_gap_align_items_end.rs
Historia
Quién tocó qué
crudo
Reinstate FlexStart and FlexEnd alignment variants (#336)
1#[test]
2fn gap_row_gap_align_items_end() {
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(20f32), 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(20f32), 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(20f32), 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(20f32), 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(20f32), height: auto() },
34 ..Default::default()
35 })
36 .unwrap();
37 let node5 = taffy
38 .new_leaf(taffy::style::Style {
39 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(20f32), height: auto() },
40 ..Default::default()
41 })
42 .unwrap();
43 let node = taffy
44 .new_with_children(
45 taffy::style::Style {
46 flex_wrap: taffy::style::FlexWrap::Wrap,
47 align_items: Some(taffy::style::AlignItems::FlexEnd),
48 gap: taffy::geometry::Size {
49 width: taffy::style::LengthPercentage::Points(10f32),
50 height: taffy::style::LengthPercentage::Points(20f32),
51 },
52 size: taffy::geometry::Size {
53 width: taffy::style::Dimension::Points(100f32),
54 height: taffy::style::Dimension::Points(200f32),
55 },
56 ..Default::default()
57 },
58 &[node0, node1, node2, node3, node4, node5],
59 )
60 .unwrap();
61 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
62 println!("\nComputed tree:");
63 taffy::debug::print_tree(&taffy, node);
64 println!();
65 let Layout { size, location, .. } = taffy.layout(node).unwrap();
66 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
67 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 200f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
70 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
71 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 20f32, size.width);
72 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, size.height);
73 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
74 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 90f32, location.y);
75 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
76 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.width);
77 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, size.height);
78 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 30f32, location.x);
79 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 90f32, location.y);
80 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
81 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 20f32, size.width);
82 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, size.height);
83 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 60f32, location.x);
84 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 90f32, location.y);
85 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
86 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3.data(), 20f32, size.width);
87 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, size.height);
88 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3.data(), 0f32, location.x);
89 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node3.data(), 200f32, location.y);
90 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
91 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4.data(), 20f32, size.width);
92 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4.data(), 0f32, size.height);
93 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4.data(), 30f32, location.x);
94 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node4.data(), 200f32, location.y);
95 let Layout { size, location, .. } = taffy.layout(node5).unwrap();
96 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5.data(), 20f32, size.width);
97 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5.data(), 0f32, size.height);
98 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5.data(), 60f32, location.x);
99 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node5.data(), 200f32, location.y);
100}