⎇ 0.3.x
tests/generated/aspect_ratio_flex_row_stretch_fill_max_height.rs
Historia
Quién tocó qué
crudo
Fixes for aspect ratio and min/max sizes (#317)
1#[test]
2fn aspect_ratio_flex_row_stretch_fill_max_height() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node0 = taffy . new_leaf_with_measure (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: Points (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , taffy :: node :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "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" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , Some (2f32)) }) ,) . unwrap () ;
8 let node = taffy
9 .new_with_children(
10 taffy::style::Style {
11 display: taffy::style::Display::Flex,
12 size: taffy::geometry::Size {
13 width: taffy::style::Dimension::Points(100f32),
14 height: taffy::style::Dimension::Points(100f32),
15 },
16 ..Default::default()
17 },
18 &[node0],
19 )
20 .unwrap();
21 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
22 println!("\nComputed tree:");
23 taffy::debug::print_tree(&taffy, node);
24 println!();
25 let Layout { size, location, .. } = taffy.layout(node).unwrap();
26 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
27 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.height);
28 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
29 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
30 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
31 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width);
32 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
35}