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