⎇ 837d03fde9d8a4efa0f4eaf1e8be2fd34a719a50
tests/generated/grid_align_content_center_negative_space_gap.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn grid_align_content_center_negative_space_gap() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node00 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node01 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
9 let node02 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
10 let node03 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
11 let node04 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
12 let node05 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
13 let node06 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
14 let node07 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
15 let node08 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 display: taffy::style::Display::Grid,
20 align_content: Some(taffy::style::AlignContent::Center),
21 justify_content: Some(taffy::style::JustifyContent::Center),
22 gap: taffy::geometry::Size {
23 width: taffy::style::LengthPercentage::Points(10f32),
24 height: taffy::style::LengthPercentage::Points(10f32),
25 },
26 grid_template_rows: vec![points(40f32), points(40f32), points(40f32)],
27 grid_template_columns: vec![points(20f32), points(20f32), points(20f32)],
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Points(120f32),
30 height: taffy::style::Dimension::Points(120f32),
31 },
32 ..Default::default()
33 },
34 &[node00, node01, node02, node03, node04, node05, node06, node07, node08],
35 )
36 .unwrap();
37 let node = taffy
38 .new_with_children(
39 taffy::style::Style {
40 display: taffy::style::Display::Grid,
41 size: taffy::geometry::Size {
42 width: taffy::style::Dimension::Points(240f32),
43 height: taffy::style::Dimension::Points(240f32),
44 },
45 border: taffy::geometry::Rect {
46 left: taffy::style::LengthPercentage::Points(60f32),
47 right: taffy::style::LengthPercentage::Points(60f32),
48 top: taffy::style::LengthPercentage::Points(60f32),
49 bottom: taffy::style::LengthPercentage::Points(60f32),
50 },
51 ..Default::default()
52 },
53 &[node0],
54 )
55 .unwrap();
56 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
57 println!("\nComputed tree:");
58 taffy::debug::print_tree(&taffy, node);
59 println!();
60 let Layout { size, location, .. } = taffy.layout(node).unwrap();
61 assert_eq!(size.width, 240f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 240f32, size.width);
62 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 240f32, size.height);
63 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
64 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
65 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
66 assert_eq!(size.width, 120f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 120f32, size.width);
67 assert_eq!(size.height, 120f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 120f32, size.height);
68 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.x);
69 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.y);
70 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
71 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.width);
72 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 40f32, size.height);
73 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, location.x);
74 assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), -10f32, location.y);
75 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
76 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 20f32, size.width);
77 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 40f32, size.height);
78 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 50f32, location.x);
79 assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), -10f32, location.y);
80 let Layout { size, location, .. } = taffy.layout(node02).unwrap();
81 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node02.data(), 20f32, size.width);
82 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node02.data(), 40f32, size.height);
83 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node02.data(), 80f32, location.x);
84 assert_eq!(location.y, -10f32, "y of node {:?}. Expected {}. Actual {}", node02.data(), -10f32, location.y);
85 let Layout { size, location, .. } = taffy.layout(node03).unwrap();
86 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node03.data(), 20f32, size.width);
87 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node03.data(), 40f32, size.height);
88 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node03.data(), 20f32, location.x);
89 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node03.data(), 40f32, location.y);
90 let Layout { size, location, .. } = taffy.layout(node04).unwrap();
91 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node04.data(), 20f32, size.width);
92 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node04.data(), 40f32, size.height);
93 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node04.data(), 50f32, location.x);
94 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node04.data(), 40f32, location.y);
95 let Layout { size, location, .. } = taffy.layout(node05).unwrap();
96 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node05.data(), 20f32, size.width);
97 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node05.data(), 40f32, size.height);
98 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node05.data(), 80f32, location.x);
99 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node05.data(), 40f32, location.y);
100 let Layout { size, location, .. } = taffy.layout(node06).unwrap();
101 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node06.data(), 20f32, size.width);
102 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node06.data(), 40f32, size.height);
103 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node06.data(), 20f32, location.x);
104 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node06.data(), 90f32, location.y);
105 let Layout { size, location, .. } = taffy.layout(node07).unwrap();
106 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node07.data(), 20f32, size.width);
107 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node07.data(), 40f32, size.height);
108 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node07.data(), 50f32, location.x);
109 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node07.data(), 90f32, location.y);
110 let Layout { size, location, .. } = taffy.layout(node08).unwrap();
111 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node08.data(), 20f32, size.width);
112 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node08.data(), 40f32, size.height);
113 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node08.data(), 80f32, location.x);
114 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node08.data(), 90f32, location.y);
115}