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