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