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