⎇ 04e20d1de5cd584bf0760071cf130dd55f5b0089
tests/generated/flex/flex_basis_unconstraint_column.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn flex_basis_unconstraint_column() {
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 flex_basis: taffy::style::Dimension::Length(50f32),
9 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 { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
16 &[node0],
17 )
18 .unwrap();
19 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
20 println!("\nComputed tree:");
21 taffy.print_tree(node);
22 println!();
23 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
24 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
25 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
26 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
27 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
28 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
29 #[cfg(feature = "content_size")]
30 assert_eq!(
31 layout.scroll_width(),
32 0f32,
33 "scroll_width of node {:?}. Expected {}. Actual {}",
34 node,
35 0f32,
36 layout.scroll_width()
37 );
38 #[cfg(feature = "content_size")]
39 assert_eq!(
40 layout.scroll_height(),
41 0f32,
42 "scroll_height of node {:?}. Expected {}. Actual {}",
43 node,
44 0f32,
45 layout.scroll_height()
46 );
47 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
48 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
49 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
50 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
52 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
53 #[cfg(feature = "content_size")]
54 assert_eq!(
55 layout.scroll_width(),
56 0f32,
57 "scroll_width of node {:?}. Expected {}. Actual {}",
58 node0,
59 0f32,
60 layout.scroll_width()
61 );
62 #[cfg(feature = "content_size")]
63 assert_eq!(
64 layout.scroll_height(),
65 0f32,
66 "scroll_height of node {:?}. Expected {}. Actual {}",
67 node0,
68 0f32,
69 layout.scroll_height()
70 );
71}