⎇ float-layout
tests/generated/block/block_overflow_scrollbars_overridden_by_available_space.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 block_overflow_scrollbars_overridden_by_available_space__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 position: taffy::style::Position::Absolute,
10 inset: taffy::geometry::Rect {
11 left: length(0f32),
12 right: length(0f32),
13 top: length(0f32),
14 bottom: length(0f32),
15 },
16 ..Default::default()
17 })
18 .unwrap();
19 let node0 = taffy
20 .new_with_children(
21 taffy::style::Style {
22 display: taffy::style::Display::Block,
23 overflow: taffy::geometry::Point {
24 x: taffy::style::Overflow::Scroll,
25 y: taffy::style::Overflow::Scroll,
26 },
27 scrollbar_width: 15f32,
28 ..Default::default()
29 },
30 &[node00],
31 )
32 .unwrap();
33 let node = taffy
34 .new_with_children(
35 taffy::style::Style {
36 display: taffy::style::Display::Block,
37 size: taffy::geometry::Size {
38 width: taffy::style::Dimension::from_length(2f32),
39 height: taffy::style::Dimension::from_length(4f32),
40 },
41 ..Default::default()
42 },
43 &[node0],
44 )
45 .unwrap();
46 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
47 println!("\nComputed tree:");
48 taffy.print_tree(node);
49 println!();
50 let layout = taffy.layout(node).unwrap();
51 let Layout { size, location, .. } = layout;
52 assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width);
53 assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height);
54 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
55 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
56 let layout = taffy.layout(node0).unwrap();
57 let Layout { size, location, .. } = layout;
58 assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width);
59 assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node0, 15f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
61 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
62 #[cfg(feature = "content_size")]
63 assert_eq!(
64 layout.scroll_width(),
65 0f32,
66 "scroll_width of node {:?}. Expected {}. Actual {}",
67 node0,
68 0f32,
69 layout.scroll_width()
70 );
71 #[cfg(feature = "content_size")]
72 assert_eq!(
73 layout.scroll_height(),
74 0f32,
75 "scroll_height of node {:?}. Expected {}. Actual {}",
76 node0,
77 0f32,
78 layout.scroll_height()
79 );
80 let layout = taffy.layout(node00).unwrap();
81 let Layout { size, location, .. } = layout;
82 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width);
83 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height);
84 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
85 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
86}
87
88#[test]
89#[allow(non_snake_case)]
90fn block_overflow_scrollbars_overridden_by_available_space__content_box() {
91 #[allow(unused_imports)]
92 use taffy::{prelude::*, Layout};
93 let mut taffy = crate::new_test_tree();
94 let node00 = taffy
95 .new_leaf(taffy::style::Style {
96 box_sizing: taffy::style::BoxSizing::ContentBox,
97 position: taffy::style::Position::Absolute,
98 inset: taffy::geometry::Rect {
99 left: length(0f32),
100 right: length(0f32),
101 top: length(0f32),
102 bottom: length(0f32),
103 },
104 ..Default::default()
105 })
106 .unwrap();
107 let node0 = taffy
108 .new_with_children(
109 taffy::style::Style {
110 display: taffy::style::Display::Block,
111 box_sizing: taffy::style::BoxSizing::ContentBox,
112 overflow: taffy::geometry::Point {
113 x: taffy::style::Overflow::Scroll,
114 y: taffy::style::Overflow::Scroll,
115 },
116 scrollbar_width: 15f32,
117 ..Default::default()
118 },
119 &[node00],
120 )
121 .unwrap();
122 let node = taffy
123 .new_with_children(
124 taffy::style::Style {
125 display: taffy::style::Display::Block,
126 box_sizing: taffy::style::BoxSizing::ContentBox,
127 size: taffy::geometry::Size {
128 width: taffy::style::Dimension::from_length(2f32),
129 height: taffy::style::Dimension::from_length(4f32),
130 },
131 ..Default::default()
132 },
133 &[node0],
134 )
135 .unwrap();
136 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
137 println!("\nComputed tree:");
138 taffy.print_tree(node);
139 println!();
140 let layout = taffy.layout(node).unwrap();
141 let Layout { size, location, .. } = layout;
142 assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node, 2f32, size.width);
143 assert_eq!(size.height, 4f32, "height of node {:?}. Expected {}. Actual {}", node, 4f32, size.height);
144 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
145 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
146 let layout = taffy.layout(node0).unwrap();
147 let Layout { size, location, .. } = layout;
148 assert_eq!(size.width, 2f32, "width of node {:?}. Expected {}. Actual {}", node0, 2f32, size.width);
149 assert_eq!(size.height, 15f32, "height of node {:?}. Expected {}. Actual {}", node0, 15f32, size.height);
150 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
151 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
152 #[cfg(feature = "content_size")]
153 assert_eq!(
154 layout.scroll_width(),
155 0f32,
156 "scroll_width of node {:?}. Expected {}. Actual {}",
157 node0,
158 0f32,
159 layout.scroll_width()
160 );
161 #[cfg(feature = "content_size")]
162 assert_eq!(
163 layout.scroll_height(),
164 0f32,
165 "scroll_height of node {:?}. Expected {}. Actual {}",
166 node0,
167 0f32,
168 layout.scroll_height()
169 );
170 let layout = taffy.layout(node00).unwrap();
171 let Layout { size, location, .. } = layout;
172 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node00, 0f32, size.width);
173 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node00, 0f32, size.height);
174 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
175 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
176}