⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_aspect_ratio_child_fill_content_height.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_aspect_ratio_child_fill_content_height__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_with_context(
9 taffy::style::Style { aspect_ratio: Some(0.5f32), ..Default::default() },
10 crate::TestNodeContext::ahem_text("HHHH", crate::WritingMode::Horizontal),
11 )
12 .unwrap();
13 let node1 = taffy
14 .new_leaf(taffy::style::Style {
15 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) },
16 ..Default::default()
17 })
18 .unwrap();
19 let node = taffy
20 .new_with_children(
21 taffy::style::Style { display: taffy::style::Display::Grid, ..Default::default() },
22 &[node0, node1],
23 )
24 .unwrap();
25 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
26 println!("\nComputed tree:");
27 taffy.print_tree(node);
28 println!();
29 let layout = taffy.layout(node).unwrap();
30 let Layout { size, location, .. } = layout;
31 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
32 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
35 let layout = taffy.layout(node0).unwrap();
36 let Layout { size, location, .. } = layout;
37 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
38 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
41 let layout = taffy.layout(node1).unwrap();
42 let Layout { size, location, .. } = layout;
43 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
44 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
46 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y);
47}
48
49#[test]
50#[allow(non_snake_case)]
51fn grid_aspect_ratio_child_fill_content_height__content_box() {
52 #[allow(unused_imports)]
53 use taffy::{prelude::*, Layout};
54 let mut taffy = crate::new_test_tree();
55 let node0 = taffy
56 .new_leaf_with_context(
57 taffy::style::Style {
58 box_sizing: taffy::style::BoxSizing::ContentBox,
59 aspect_ratio: Some(0.5f32),
60 ..Default::default()
61 },
62 crate::TestNodeContext::ahem_text("HHHH", crate::WritingMode::Horizontal),
63 )
64 .unwrap();
65 let node1 = taffy
66 .new_leaf(taffy::style::Style {
67 box_sizing: taffy::style::BoxSizing::ContentBox,
68 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(20f32) },
69 ..Default::default()
70 })
71 .unwrap();
72 let node = taffy
73 .new_with_children(
74 taffy::style::Style {
75 display: taffy::style::Display::Grid,
76 box_sizing: taffy::style::BoxSizing::ContentBox,
77 ..Default::default()
78 },
79 &[node0, node1],
80 )
81 .unwrap();
82 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
83 println!("\nComputed tree:");
84 taffy.print_tree(node);
85 println!();
86 let layout = taffy.layout(node).unwrap();
87 let Layout { size, location, .. } = layout;
88 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
89 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
90 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
91 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
92 let layout = taffy.layout(node0).unwrap();
93 let Layout { size, location, .. } = layout;
94 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
95 assert_eq!(size.height, 80f32, "height of node {:?}. Expected {}. Actual {}", node0, 80f32, size.height);
96 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
97 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
98 let layout = taffy.layout(node1).unwrap();
99 let Layout { size, location, .. } = layout;
100 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
101 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
102 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
103 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y);
104}