⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/aspect_ratio_flex_column_fill_min_width.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn aspect_ratio_flex_column_fill_min_width__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf_with_context(
9 taffy::style::Style {
10 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) },
11 aspect_ratio: Some(2f32),
12 ..Default::default()
13 },
14 crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal),
15 )
16 .unwrap();
17 let node = taffy
18 .new_with_children(
19 taffy::style::Style {
20 display: taffy::style::Display::Flex,
21 flex_direction: taffy::style::FlexDirection::Column,
22 align_items: Some(taffy::style::AlignItems::Start),
23 size: taffy::geometry::Size {
24 width: taffy::style::Dimension::from_length(100f32),
25 height: taffy::style::Dimension::from_length(100f32),
26 },
27 ..Default::default()
28 },
29 &[node0],
30 )
31 .unwrap();
32 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
33 println!("\nComputed tree:");
34 taffy.print_tree(node);
35 println!();
36 let layout = taffy.layout(node).unwrap();
37 let Layout { size, location, .. } = layout;
38 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
39 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
42 let layout = taffy.layout(node0).unwrap();
43 let Layout { size, location, .. } = layout;
44 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
45 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
46 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
47 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
48}
49
50#[test]
51#[allow(non_snake_case)]
52fn aspect_ratio_flex_column_fill_min_width__content_box() {
53 #[allow(unused_imports)]
54 use taffy::{prelude::*, Layout};
55 let mut taffy = crate::new_test_tree();
56 let node0 = taffy
57 .new_leaf_with_context(
58 taffy::style::Style {
59 box_sizing: taffy::style::BoxSizing::ContentBox,
60 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) },
61 aspect_ratio: Some(2f32),
62 ..Default::default()
63 },
64 crate::TestNodeContext::ahem_text("", crate::WritingMode::Horizontal),
65 )
66 .unwrap();
67 let node = taffy
68 .new_with_children(
69 taffy::style::Style {
70 display: taffy::style::Display::Flex,
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 flex_direction: taffy::style::FlexDirection::Column,
73 align_items: Some(taffy::style::AlignItems::Start),
74 size: taffy::geometry::Size {
75 width: taffy::style::Dimension::from_length(100f32),
76 height: taffy::style::Dimension::from_length(100f32),
77 },
78 ..Default::default()
79 },
80 &[node0],
81 )
82 .unwrap();
83 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
84 println!("\nComputed tree:");
85 taffy.print_tree(node);
86 println!();
87 let layout = taffy.layout(node).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
90 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
93 let layout = taffy.layout(node0).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
96 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
97 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
98 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
99}