⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/align_content_spacebetween.rs
Historia
Quién tocó qué
crudo
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn align_content_spacebetween() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Length(50f32),
10 height: taffy::style::Dimension::Length(10f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node1 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(50f32),
19 height: taffy::style::Dimension::Length(10f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node2 = taffy
25 .new_leaf(taffy::style::Style {
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::Length(50f32),
28 height: taffy::style::Dimension::Length(10f32),
29 },
30 ..Default::default()
31 })
32 .unwrap();
33 let node3 = taffy
34 .new_leaf(taffy::style::Style {
35 size: taffy::geometry::Size {
36 width: taffy::style::Dimension::Length(50f32),
37 height: taffy::style::Dimension::Length(10f32),
38 },
39 ..Default::default()
40 })
41 .unwrap();
42 let node4 = taffy
43 .new_leaf(taffy::style::Style {
44 size: taffy::geometry::Size {
45 width: taffy::style::Dimension::Length(50f32),
46 height: taffy::style::Dimension::Length(10f32),
47 },
48 ..Default::default()
49 })
50 .unwrap();
51 let node = taffy
52 .new_with_children(
53 taffy::style::Style {
54 flex_wrap: taffy::style::FlexWrap::Wrap,
55 align_content: Some(taffy::style::AlignContent::SpaceBetween),
56 size: taffy::geometry::Size {
57 width: taffy::style::Dimension::Length(130f32),
58 height: taffy::style::Dimension::Length(100f32),
59 },
60 ..Default::default()
61 },
62 &[node0, node1, node2, node3, node4],
63 )
64 .unwrap();
65 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
66 println!("\nComputed tree:");
67 taffy::util::print_tree(&taffy, node);
68 println!();
69 let Layout { size, location, .. } = taffy.layout(node).unwrap();
70 assert_eq!(size.width, 130f32, "width of node {:?}. Expected {}. Actual {}", node, 130f32, size.width);
71 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
72 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
73 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
74 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
75 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
76 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
79 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
80 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
81 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
82 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node1, 50f32, location.x);
83 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
84 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
85 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node2, 50f32, size.width);
86 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
87 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
88 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node2, 45f32, location.y);
89 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
90 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node3, 50f32, size.width);
91 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node3, 10f32, size.height);
92 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x);
93 assert_eq!(location.y, 45f32, "y of node {:?}. Expected {}. Actual {}", node3, 45f32, location.y);
94 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
95 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node4, 50f32, size.width);
96 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node4, 10f32, size.height);
97 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
98 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node4, 90f32, location.y);
99}