⎇ 0.5.x
tests/generated/flex/min_width_overrides_width_on_root.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn min_width_overrides_width_on_root() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
9 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
10 ..Default::default()
11 })
12 .unwrap();
13 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
14 println!("\nComputed tree:");
15 taffy.print_tree(node);
16 println!();
17 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
18 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
19 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
20 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
21 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
22 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
23 #[cfg(feature = "content_size")]
24 assert_eq!(
25 layout.scroll_width(),
26 0f32,
27 "scroll_width of node {:?}. Expected {}. Actual {}",
28 node,
29 0f32,
30 layout.scroll_width()
31 );
32 #[cfg(feature = "content_size")]
33 assert_eq!(
34 layout.scroll_height(),
35 0f32,
36 "scroll_height of node {:?}. Expected {}. Actual {}",
37 node,
38 0f32,
39 layout.scroll_height()
40 );
41}