⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/gap_column_gap_wrap_align_space_between.rs
History
Who touched what
raw
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn gap_column_gap_wrap_align_space_between() {
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(20f32),
10 height: taffy::style::Dimension::Length(20f32),
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(20f32),
19 height: taffy::style::Dimension::Length(20f32),
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(20f32),
28 height: taffy::style::Dimension::Length(20f32),
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(20f32),
37 height: taffy::style::Dimension::Length(20f32),
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(20f32),
46 height: taffy::style::Dimension::Length(20f32),
47 },
48 ..Default::default()
49 })
50 .unwrap();
51 let node5 = taffy
52 .new_leaf(taffy::style::Style {
53 size: taffy::geometry::Size {
54 width: taffy::style::Dimension::Length(20f32),
55 height: taffy::style::Dimension::Length(20f32),
56 },
57 ..Default::default()
58 })
59 .unwrap();
60 let node = taffy
61 .new_with_children(
62 taffy::style::Style {
63 flex_wrap: taffy::style::FlexWrap::Wrap,
64 align_content: Some(taffy::style::AlignContent::SpaceBetween),
65 gap: taffy::geometry::Size {
66 width: taffy::style::LengthPercentage::Length(10f32),
67 height: taffy::style::LengthPercentage::Length(20f32),
68 },
69 size: taffy::geometry::Size {
70 width: taffy::style::Dimension::Length(100f32),
71 height: taffy::style::Dimension::Length(100f32),
72 },
73 ..Default::default()
74 },
75 &[node0, node1, node2, node3, node4, node5],
76 )
77 .unwrap();
78 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
79 println!("\nComputed tree:");
80 taffy::util::print_tree(&taffy, node);
81 println!();
82 let Layout { size, location, .. } = taffy.layout(node).unwrap();
83 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
84 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
85 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
86 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
87 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
88 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
89 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
90 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
91 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
92 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
93 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
94 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
95 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node1, 30f32, location.x);
96 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
97 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
98 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node2, 20f32, size.width);
99 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
100 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
101 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
102 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
103 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node3, 20f32, size.width);
104 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node3, 20f32, size.height);
105 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
106 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node3, 80f32, location.y);
107 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
108 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node4, 20f32, size.width);
109 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node4, 20f32, size.height);
110 assert_eq!(location.x, 30f32, "x of node {:?}. Expected {}. Actual {}", node4, 30f32, location.x);
111 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node4, 80f32, location.y);
112 let Layout { size, location, .. } = taffy.layout(node5).unwrap();
113 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node5, 20f32, size.width);
114 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node5, 20f32, size.height);
115 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node5, 60f32, location.x);
116 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node5, 80f32, location.y);
117}