⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/block/block_absolute_child_with_max_height.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn block_absolute_child_with_max_height__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 display: taffy::style::Display::Block,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_length(100f32),
12 height: taffy::style::Dimension::from_length(150f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node0 = taffy
18 .new_with_children(
19 taffy::style::Style {
20 display: taffy::style::Display::Block,
21 position: taffy::style::Position::Absolute,
22 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
23 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) },
24 ..Default::default()
25 },
26 &[node00],
27 )
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 display: taffy::style::Display::Block,
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::from_length(100f32),
35 height: taffy::style::Dimension::from_length(200f32),
36 },
37 ..Default::default()
38 },
39 &[node0],
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, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
49 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, 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, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
55 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
57 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
58 let layout = taffy.layout(node00).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width);
61 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height);
62 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
64}
65
66#[test]
67#[allow(non_snake_case)]
68fn block_absolute_child_with_max_height__content_box() {
69 #[allow(unused_imports)]
70 use taffy::{prelude::*, Layout};
71 let mut taffy = crate::new_test_tree();
72 let node00 = taffy
73 .new_leaf(taffy::style::Style {
74 display: taffy::style::Display::Block,
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(150f32),
79 },
80 ..Default::default()
81 })
82 .unwrap();
83 let node0 = taffy
84 .new_with_children(
85 taffy::style::Style {
86 display: taffy::style::Display::Block,
87 box_sizing: taffy::style::BoxSizing::ContentBox,
88 position: taffy::style::Position::Absolute,
89 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
90 inset: taffy::geometry::Rect { left: auto(), right: auto(), top: auto(), bottom: length(20f32) },
91 ..Default::default()
92 },
93 &[node00],
94 )
95 .unwrap();
96 let node = taffy
97 .new_with_children(
98 taffy::style::Style {
99 display: taffy::style::Display::Block,
100 box_sizing: taffy::style::BoxSizing::ContentBox,
101 size: taffy::geometry::Size {
102 width: taffy::style::Dimension::from_length(100f32),
103 height: taffy::style::Dimension::from_length(200f32),
104 },
105 ..Default::default()
106 },
107 &[node0],
108 )
109 .unwrap();
110 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
111 println!("\nComputed tree:");
112 taffy.print_tree(node);
113 println!();
114 let layout = taffy.layout(node).unwrap();
115 let Layout { size, location, .. } = layout;
116 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
117 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node, 200f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
120 let layout = taffy.layout(node0).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
123 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
124 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
125 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
126 let layout = taffy.layout(node00).unwrap();
127 let Layout { size, location, .. } = layout;
128 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node00, 100f32, size.width);
129 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height);
130 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
131 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
132}