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