⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_span_2_max_content_auto_indefinite.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Add `taffy_test_helpers` crate (#755)
1#[test]
2#[allow(non_snake_case)]
3fn grid_span_2_max_content_auto_indefinite__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
10 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
11 ..Default::default()
12 })
13 .unwrap();
14 let node1 = taffy
15 .new_leaf(taffy::style::Style {
16 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
17 grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto },
18 ..Default::default()
19 })
20 .unwrap();
21 let node2 = taffy
22 .new_leaf_with_context(
23 taffy::style::Style {
24 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
25 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) },
26 ..Default::default()
27 },
28 crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal),
29 )
30 .unwrap();
31 let node = taffy
32 .new_with_children(
33 taffy::style::Style {
34 display: taffy::style::Display::Grid,
35 grid_template_rows: vec![length(40f32)],
36 grid_template_columns: vec![max_content(), auto()],
37 ..Default::default()
38 },
39 &[node0, node1, node2],
40 )
41 .unwrap();
42 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
43 println!("\nComputed tree:");
44 taffy.print_tree(node);
45 println!();
46 let layout = taffy.layout(node).unwrap();
47 let Layout { size, location, .. } = layout;
48 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
49 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
50 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
51 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
52 let layout = taffy.layout(node0).unwrap();
53 let Layout { size, location, .. } = layout;
54 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
55 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
58 let layout = taffy.layout(node1).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
61 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
62 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
64 let layout = taffy.layout(node2).unwrap();
65 let Layout { size, location, .. } = layout;
66 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width);
67 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
70}
71
72#[test]
73#[allow(non_snake_case)]
74fn grid_span_2_max_content_auto_indefinite__content_box() {
75 #[allow(unused_imports)]
76 use taffy::{prelude::*, Layout};
77 let mut taffy = crate::new_test_tree();
78 let node0 = taffy
79 .new_leaf(taffy::style::Style {
80 box_sizing: taffy::style::BoxSizing::ContentBox,
81 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
82 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
83 ..Default::default()
84 })
85 .unwrap();
86 let node1 = taffy
87 .new_leaf(taffy::style::Style {
88 box_sizing: taffy::style::BoxSizing::ContentBox,
89 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
90 grid_column: taffy::geometry::Line { start: line(2i16), end: taffy::style::GridPlacement::Auto },
91 ..Default::default()
92 })
93 .unwrap();
94 let node2 = taffy
95 .new_leaf_with_context(
96 taffy::style::Style {
97 box_sizing: taffy::style::BoxSizing::ContentBox,
98 grid_row: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Auto },
99 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) },
100 ..Default::default()
101 },
102 crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal),
103 )
104 .unwrap();
105 let node = taffy
106 .new_with_children(
107 taffy::style::Style {
108 display: taffy::style::Display::Grid,
109 box_sizing: taffy::style::BoxSizing::ContentBox,
110 grid_template_rows: vec![length(40f32)],
111 grid_template_columns: vec![max_content(), auto()],
112 ..Default::default()
113 },
114 &[node0, node1, node2],
115 )
116 .unwrap();
117 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
118 println!("\nComputed tree:");
119 taffy.print_tree(node);
120 println!();
121 let layout = taffy.layout(node).unwrap();
122 let Layout { size, location, .. } = layout;
123 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
124 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
125 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
126 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
127 let layout = taffy.layout(node0).unwrap();
128 let Layout { size, location, .. } = layout;
129 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
130 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
131 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
132 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
133 let layout = taffy.layout(node1).unwrap();
134 let Layout { size, location, .. } = layout;
135 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1, 20f32, size.width);
136 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
137 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node1, 60f32, location.x);
138 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
139 let layout = taffy.layout(node2).unwrap();
140 let Layout { size, location, .. } = layout;
141 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width);
142 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
143 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
144 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
145}