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