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