⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/aspect_ratio_flex_row_fill_max_height.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn aspect_ratio_flex_row_fill_max_height__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("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" , crate :: WritingMode :: Horizontal) ,) . unwrap () ;
8 let node = taffy
9 .new_with_children(
10 taffy::style::Style {
11 display: taffy::style::Display::Flex,
12 align_items: Some(taffy::style::AlignItems::Start),
13 size: taffy::geometry::Size {
14 width: taffy::style::Dimension::from_length(100f32),
15 height: taffy::style::Dimension::from_length(100f32),
16 },
17 ..Default::default()
18 },
19 &[node0],
20 )
21 .unwrap();
22 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
23 println!("\nComputed tree:");
24 taffy.print_tree(node);
25 println!();
26 let layout = taffy.layout(node).unwrap();
27 let Layout { size, location, .. } = layout;
28 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
29 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
30 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
31 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
32 let layout = taffy.layout(node0).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
35 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
38}
39
40#[test]
41#[allow(non_snake_case)]
42fn aspect_ratio_flex_row_fill_max_height__content_box() {
43 #[allow(unused_imports)]
44 use taffy::{prelude::*, Layout};
45 let mut taffy = crate::new_test_tree();
46 let node0 = taffy . new_leaf_with_context (taffy :: style :: Style { box_sizing : taffy :: style :: BoxSizing :: ContentBox , max_size : taffy :: geometry :: Size { width : taffy :: style :: Dimension :: from_length (40f32) , height : auto () , } , aspect_ratio : Some (2f32) , .. Default :: default () } , crate :: TestNodeContext :: ahem_text ("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" , crate :: WritingMode :: Horizontal) ,) . unwrap () ;
47 let node = taffy
48 .new_with_children(
49 taffy::style::Style {
50 display: taffy::style::Display::Flex,
51 box_sizing: taffy::style::BoxSizing::ContentBox,
52 align_items: Some(taffy::style::AlignItems::Start),
53 size: taffy::geometry::Size {
54 width: taffy::style::Dimension::from_length(100f32),
55 height: taffy::style::Dimension::from_length(100f32),
56 },
57 ..Default::default()
58 },
59 &[node0],
60 )
61 .unwrap();
62 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
63 println!("\nComputed tree:");
64 taffy.print_tree(node);
65 println!();
66 let layout = taffy.layout(node).unwrap();
67 let Layout { size, location, .. } = layout;
68 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
69 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
70 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
72 let layout = taffy.layout(node0).unwrap();
73 let Layout { size, location, .. } = layout;
74 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
75 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
76 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
77 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
78}