⎇ cd73db35cfa2b31555a796e7972cd97a45554e17
tests/generated/flex/undefined_width_with_min_max.rs
History
Who touched what
raw
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn undefined_width_with_min_max() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() },
9 max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 let node = taffy
14 .new_with_children(
15 taffy::style::Style {
16 flex_direction: taffy::style::FlexDirection::Column,
17 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) },
18 ..Default::default()
19 },
20 &[node0],
21 )
22 .unwrap();
23 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
24 println!("\nComputed tree:");
25 taffy.print_tree(node);
26 println!();
27 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
28 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
29 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
30 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
31 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
32 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
33 #[cfg(feature = "content_size")]
34 assert_eq!(
35 layout.scroll_width(),
36 0f32,
37 "scroll_width of node {:?}. Expected {}. Actual {}",
38 node,
39 0f32,
40 layout.scroll_width()
41 );
42 #[cfg(feature = "content_size")]
43 assert_eq!(
44 layout.scroll_height(),
45 0f32,
46 "scroll_height of node {:?}. Expected {}. Actual {}",
47 node,
48 0f32,
49 layout.scroll_height()
50 );
51 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
52 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
53 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
54 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
57 #[cfg(feature = "content_size")]
58 assert_eq!(
59 layout.scroll_width(),
60 0f32,
61 "scroll_width of node {:?}. Expected {}. Actual {}",
62 node0,
63 0f32,
64 layout.scroll_width()
65 );
66 #[cfg(feature = "content_size")]
67 assert_eq!(
68 layout.scroll_height(),
69 0f32,
70 "scroll_height of node {:?}. Expected {}. Actual {}",
71 node0,
72 0f32,
73 layout.scroll_height()
74 );
75}