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