⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_span_2_min_content_auto_indefinite.rs
Historia
Quién tocó qué
crudo
Add `taffy_test_helpers` crate (#755)
1#[test]
2#[allow(non_snake_case)]
3fn grid_span_2_min_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.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
9 let node2 = taffy
10 .new_leaf_with_context(
11 taffy::style::Style {
12 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) },
13 ..Default::default()
14 },
15 crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal),
16 )
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 display: taffy::style::Display::Grid,
22 grid_template_rows: vec![length(40f32)],
23 grid_template_columns: vec![min_content(), auto()],
24 ..Default::default()
25 },
26 &[node0, node1, node2],
27 )
28 .unwrap();
29 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
30 println!("\nComputed tree:");
31 taffy.print_tree(node);
32 println!();
33 let layout = taffy.layout(node).unwrap();
34 let Layout { size, location, .. } = layout;
35 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
36 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
37 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
38 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
39 let layout = taffy.layout(node0).unwrap();
40 let Layout { size, location, .. } = layout;
41 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
42 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
43 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
44 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
45 let layout = taffy.layout(node1).unwrap();
46 let Layout { size, location, .. } = layout;
47 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width);
48 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
49 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
51 let layout = taffy.layout(node2).unwrap();
52 let Layout { size, location, .. } = layout;
53 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width);
54 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
56 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y);
57}
58
59#[test]
60#[allow(non_snake_case)]
61fn grid_span_2_min_content_auto_indefinite__content_box() {
62 #[allow(unused_imports)]
63 use taffy::{prelude::*, Layout};
64 let mut taffy = crate::new_test_tree();
65 let node0 = taffy
66 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
67 .unwrap();
68 let node1 = taffy
69 .new_leaf(taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() })
70 .unwrap();
71 let node2 = taffy
72 .new_leaf_with_context(
73 taffy::style::Style {
74 box_sizing: taffy::style::BoxSizing::ContentBox,
75 grid_column: taffy::geometry::Line { start: line(1i16), end: taffy::style::GridPlacement::Span(2u16) },
76 ..Default::default()
77 },
78 crate::TestNodeContext::ahem_text("HHHH\u{200b}HHHH", crate::WritingMode::Horizontal),
79 )
80 .unwrap();
81 let node = taffy
82 .new_with_children(
83 taffy::style::Style {
84 display: taffy::style::Display::Grid,
85 box_sizing: taffy::style::BoxSizing::ContentBox,
86 grid_template_rows: vec![length(40f32)],
87 grid_template_columns: vec![min_content(), auto()],
88 ..Default::default()
89 },
90 &[node0, node1, node2],
91 )
92 .unwrap();
93 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
94 println!("\nComputed tree:");
95 taffy.print_tree(node);
96 println!();
97 let layout = taffy.layout(node).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node, 80f32, size.width);
100 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
102 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
103 let layout = taffy.layout(node0).unwrap();
104 let Layout { size, location, .. } = layout;
105 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
106 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
107 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
108 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
109 let layout = taffy.layout(node1).unwrap();
110 let Layout { size, location, .. } = layout;
111 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width);
112 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
113 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x);
114 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
115 let layout = taffy.layout(node2).unwrap();
116 let Layout { size, location, .. } = layout;
117 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node2, 80f32, size.width);
118 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
119 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
120 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node2, 40f32, location.y);
121}