⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/overflow_scrollbars_take_up_space_both_axis.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn overflow_scrollbars_take_up_space_both_axis__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
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::Scroll,
14 },
15 scrollbar_width: 15f32,
16 size: taffy::geometry::Size {
17 width: taffy::style::Dimension::from_length(50f32),
18 height: taffy::style::Dimension::from_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 let layout = taffy.layout(node).unwrap();
30 let Layout { size, location, .. } = layout;
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 let layout = taffy.layout(node0).unwrap();
54 let Layout { size, location, .. } = layout;
55 assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, 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}
60
61#[test]
62#[allow(non_snake_case)]
63fn overflow_scrollbars_take_up_space_both_axis__content_box() {
64 #[allow(unused_imports)]
65 use taffy::{prelude::*, Layout};
66 let mut taffy = crate::new_test_tree();
67 let node0 = taffy
68 .new_leaf(taffy::style::Style {
69 box_sizing: taffy::style::BoxSizing::ContentBox,
70 flex_grow: 1f32,
71 ..Default::default()
72 })
73 .unwrap();
74 let node = taffy
75 .new_with_children(
76 taffy::style::Style {
77 box_sizing: taffy::style::BoxSizing::ContentBox,
78 overflow: taffy::geometry::Point {
79 x: taffy::style::Overflow::Scroll,
80 y: taffy::style::Overflow::Scroll,
81 },
82 scrollbar_width: 15f32,
83 size: taffy::geometry::Size {
84 width: taffy::style::Dimension::from_length(50f32),
85 height: taffy::style::Dimension::from_length(50f32),
86 },
87 ..Default::default()
88 },
89 &[node0],
90 )
91 .unwrap();
92 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
93 println!("\nComputed tree:");
94 taffy.print_tree(node);
95 println!();
96 let layout = taffy.layout(node).unwrap();
97 let Layout { size, location, .. } = layout;
98 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
99 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
100 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
101 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
102 #[cfg(feature = "content_size")]
103 assert_eq!(
104 layout.scroll_width(),
105 0f32,
106 "scroll_width of node {:?}. Expected {}. Actual {}",
107 node,
108 0f32,
109 layout.scroll_width()
110 );
111 #[cfg(feature = "content_size")]
112 assert_eq!(
113 layout.scroll_height(),
114 0f32,
115 "scroll_height of node {:?}. Expected {}. Actual {}",
116 node,
117 0f32,
118 layout.scroll_height()
119 );
120 let layout = taffy.layout(node0).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 35f32, "width of node {:?}. Expected {}. Actual {}", node0, 35f32, size.width);
123 assert_eq!(size.height, 35f32, "height of node {:?}. Expected {}. Actual {}", node0, 35f32, size.height);
124 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
125 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
126}