⎇ 3bc35ec3b541eea8ea62344722f155ce9b22e227
tests/generated/flex/overflow_scrollbars_take_up_space_main_axis.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn overflow_scrollbars_take_up_space_main_axis__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
8 let node = 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::Visible,
14 },
15 scrollbar_width: 15f32,
16 size: taffy::geometry::Size {
17 width: taffy::style::Dimension::Length(50f32),
18 height: taffy::style::Dimension::Length(50f32),
19 },
20 ..Default::default()
21 },
22 &[node0],
23 )
24 .unwrap();
25 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
26 println!("\nComputed tree:");
27 taffy.print_tree(node);
28 println!();
29 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
30 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
31 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
32 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
35 #[cfg(feature = "content_size")]
36 assert_eq!(
37 layout.scroll_width(),
38 0f32,
39 "scroll_width of node {:?}. Expected {}. Actual {}",
40 node,
41 0f32,
42 layout.scroll_width()
43 );
44 #[cfg(feature = "content_size")]
45 assert_eq!(
46 layout.scroll_height(),
47 0f32,
48 "scroll_height of node {:?}. Expected {}. Actual {}",
49 node,
50 0f32,
51 layout.scroll_height()
52 );
53 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
54 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
55 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
56 assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height);
57 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
58 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
59 #[cfg(feature = "content_size")]
60 assert_eq!(
61 layout.scroll_width(),
62 0f32,
63 "scroll_width of node {:?}. Expected {}. Actual {}",
64 node0,
65 0f32,
66 layout.scroll_width()
67 );
68 #[cfg(feature = "content_size")]
69 assert_eq!(
70 layout.scroll_height(),
71 0f32,
72 "scroll_height of node {:?}. Expected {}. Actual {}",
73 node0,
74 0f32,
75 layout.scroll_height()
76 );
77}
78
79#[test]
80#[allow(non_snake_case)]
81fn overflow_scrollbars_take_up_space_main_axis__content_box() {
82 #[allow(unused_imports)]
83 use taffy::{prelude::*, tree::Layout, TaffyTree};
84 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
85 let node0 = taffy
86 .new_leaf(taffy::style::Style {
87 box_sizing: taffy::style::BoxSizing::ContentBox,
88 flex_grow: 1f32,
89 ..Default::default()
90 })
91 .unwrap();
92 let node = taffy
93 .new_with_children(
94 taffy::style::Style {
95 box_sizing: taffy::style::BoxSizing::ContentBox,
96 overflow: taffy::geometry::Point {
97 x: taffy::style::Overflow::Scroll,
98 y: taffy::style::Overflow::Visible,
99 },
100 scrollbar_width: 15f32,
101 size: taffy::geometry::Size {
102 width: taffy::style::Dimension::Length(50f32),
103 height: taffy::style::Dimension::Length(50f32),
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 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
115 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
116 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
117 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, 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 #[cfg(feature = "content_size")]
121 assert_eq!(
122 layout.scroll_width(),
123 0f32,
124 "scroll_width of node {:?}. Expected {}. Actual {}",
125 node,
126 0f32,
127 layout.scroll_width()
128 );
129 #[cfg(feature = "content_size")]
130 assert_eq!(
131 layout.scroll_height(),
132 0f32,
133 "scroll_height of node {:?}. Expected {}. Actual {}",
134 node,
135 0f32,
136 layout.scroll_height()
137 );
138 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
139 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
140 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
141 assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height);
142 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
143 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
144 #[cfg(feature = "content_size")]
145 assert_eq!(
146 layout.scroll_width(),
147 0f32,
148 "scroll_width of node {:?}. Expected {}. Actual {}",
149 node0,
150 0f32,
151 layout.scroll_width()
152 );
153 #[cfg(feature = "content_size")]
154 assert_eq!(
155 layout.scroll_height(),
156 0f32,
157 "scroll_height of node {:?}. Expected {}. Actual {}",
158 node0,
159 0f32,
160 layout.scroll_height()
161 );
162}