⎇ c154b8aa719da0d6f8636b123765a47fa40a3306
tests/generated/flex/measure_width_overrides_measure.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn measure_width_overrides_measure() {
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_with_context(
8 taffy::style::Style {
9 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
10 ..Default::default()
11 },
12 crate::TextMeasure {
13 text_content: "HHHHHHHHHH",
14 writing_mode: crate::WritingMode::Horizontal,
15 _aspect_ratio: None,
16 },
17 )
18 .unwrap();
19 let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
20 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
21 println!("\nComputed tree:");
22 taffy.print_tree(node);
23 println!();
24 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
25 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
26 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
27 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
28 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
29 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
30 #[cfg(feature = "content_size")]
31 assert_eq!(
32 layout.scroll_width(),
33 50f32,
34 "scroll_width of node {:?}. Expected {}. Actual {}",
35 node,
36 50f32,
37 layout.scroll_width()
38 );
39 #[cfg(feature = "content_size")]
40 assert_eq!(
41 layout.scroll_height(),
42 0f32,
43 "scroll_height of node {:?}. Expected {}. Actual {}",
44 node,
45 0f32,
46 layout.scroll_height()
47 );
48 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
49 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
50 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
51 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
52 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
53 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
54 #[cfg(feature = "content_size")]
55 assert_eq!(
56 layout.scroll_width(),
57 50f32,
58 "scroll_width of node {:?}. Expected {}. Actual {}",
59 node0,
60 50f32,
61 layout.scroll_width()
62 );
63 #[cfg(feature = "content_size")]
64 assert_eq!(
65 layout.scroll_height(),
66 0f32,
67 "scroll_height of node {:?}. Expected {}. Actual {}",
68 node0,
69 0f32,
70 layout.scroll_height()
71 );
72}