⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/overflow_main_axis_shrink_hidden.rs
Historia
Quién tocó qué
crudo
Support `Overflow::Scroll` (#446)
1#[test]
2fn overflow_main_axis_shrink_hidden() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf_with_measure(
8 taffy::style::Style {
9 overflow: taffy::geometry::Point {
10 x: taffy::style::Overflow::Hidden,
11 y: taffy::style::Overflow::Hidden,
12 },
13 scrollbar_width: 15f32,
14 flex_shrink: 1f32,
15 ..Default::default()
16 },
17 taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| {
18 const TEXT: &str = "HHHHHHHHHH";
19 super::measure_standard_text(
20 known_dimensions,
21 available_space,
22 TEXT,
23 super::WritingMode::Horizontal,
24 None,
25 )
26 }),
27 )
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 size: taffy::geometry::Size {
33 width: taffy::style::Dimension::Length(50f32),
34 height: taffy::style::Dimension::Length(50f32),
35 },
36 ..Default::default()
37 },
38 &[node0],
39 )
40 .unwrap();
41 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
42 println!("\nComputed tree:");
43 taffy::util::print_tree(&taffy, node);
44 println!();
45 let Layout { size, location, .. } = taffy.layout(node).unwrap();
46 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
47 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
48 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
49 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
50 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
51 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
52 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
53 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
55}