⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/aspect_ratio_flex_column_fill_width.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn aspect_ratio_flex_column_fill_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(taffy::style::Style {
9 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) },
10 aspect_ratio: Some(2f32),
11 ..Default::default()
12 })
13 .unwrap();
14 let node = taffy
15 .new_with_children(
16 taffy::style::Style {
17 display: taffy::style::Display::Flex,
18 flex_direction: taffy::style::FlexDirection::Column,
19 align_items: Some(taffy::style::AlignItems::Start),
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::from_length(100f32),
22 height: taffy::style::Dimension::from_length(100f32),
23 },
24 ..Default::default()
25 },
26 &[node0],
27 )
28 .unwrap();
29 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
30 println!("\nComputed tree:");
31 taffy.print_tree(node);
32 println!();
33 let layout = taffy.layout(node).unwrap();
34 let Layout { size, location, .. } = layout;
35 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
36 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
37 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
38 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
39 let layout = taffy.layout(node0).unwrap();
40 let Layout { size, location, .. } = layout;
41 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
42 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
43 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
44 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
45}
46
47#[test]
48#[allow(non_snake_case)]
49fn aspect_ratio_flex_column_fill_width__content_box() {
50 #[allow(unused_imports)]
51 use taffy::{prelude::*, Layout};
52 let mut taffy = crate::new_test_tree();
53 let node0 = taffy
54 .new_leaf(taffy::style::Style {
55 box_sizing: taffy::style::BoxSizing::ContentBox,
56 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) },
57 aspect_ratio: Some(2f32),
58 ..Default::default()
59 })
60 .unwrap();
61 let node = taffy
62 .new_with_children(
63 taffy::style::Style {
64 display: taffy::style::Display::Flex,
65 box_sizing: taffy::style::BoxSizing::ContentBox,
66 flex_direction: taffy::style::FlexDirection::Column,
67 align_items: Some(taffy::style::AlignItems::Start),
68 size: taffy::geometry::Size {
69 width: taffy::style::Dimension::from_length(100f32),
70 height: taffy::style::Dimension::from_length(100f32),
71 },
72 ..Default::default()
73 },
74 &[node0],
75 )
76 .unwrap();
77 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
78 println!("\nComputed tree:");
79 taffy.print_tree(node);
80 println!();
81 let layout = taffy.layout(node).unwrap();
82 let Layout { size, location, .. } = layout;
83 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
84 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
85 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
86 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
87 let layout = taffy.layout(node0).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
90 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
93}