⎇ fd9112585b697975a342fdb76ca5b263a2b62891
tests/generated/block/block_aspect_ratio_fill_max_height.rs
History
Who touched what
raw
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn block_aspect_ratio_fill_max_height() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { display : taffy :: style :: Display :: Block , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TextMeasure { text_content : "HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH\u{200b}HH" , writing_mode : crate :: WritingMode :: Horizontal , _aspect_ratio : Some (2f32) , } ,) . unwrap () ;
7 let node = taffy
8 .new_with_children(
9 taffy::style::Style {
10 display: taffy::style::Display::Block,
11 size: taffy::geometry::Size {
12 width: taffy::style::Dimension::Length(100f32),
13 height: taffy::style::Dimension::Length(100f32),
14 },
15 ..Default::default()
16 },
17 &[node0],
18 )
19 .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, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
27 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, 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 0f32,
34 "scroll_width of node {:?}. Expected {}. Actual {}",
35 node,
36 0f32,
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, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
51 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node0, 60f32, 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 0f32,
58 "scroll_width of node {:?}. Expected {}. Actual {}",
59 node0,
60 0f32,
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}