⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/aspect_ratio_flex_row_fill_width.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_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 align_items: Some(taffy::style::AlignItems::Start),
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(100f32),
21 height: taffy::style::Dimension::from_length(100f32),
22 },
23 ..Default::default()
24 },
25 &[node0],
26 )
27 .unwrap();
28 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
29 println!("\nComputed tree:");
30 taffy.print_tree(node);
31 println!();
32 let layout = taffy.layout(node).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
35 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
38 let layout = taffy.layout(node0).unwrap();
39 let Layout { size, location, .. } = layout;
40 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
41 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
42 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
43 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
44}
45
46#[test]
47#[allow(non_snake_case)]
48fn aspect_ratio_flex_row_fill_width__content_box() {
49 #[allow(unused_imports)]
50 use taffy::{prelude::*, Layout};
51 let mut taffy = crate::new_test_tree();
52 let node0 = taffy
53 .new_leaf(taffy::style::Style {
54 box_sizing: taffy::style::BoxSizing::ContentBox,
55 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(40f32) },
56 aspect_ratio: Some(2f32),
57 ..Default::default()
58 })
59 .unwrap();
60 let node = taffy
61 .new_with_children(
62 taffy::style::Style {
63 display: taffy::style::Display::Flex,
64 box_sizing: taffy::style::BoxSizing::ContentBox,
65 align_items: Some(taffy::style::AlignItems::Start),
66 size: taffy::geometry::Size {
67 width: taffy::style::Dimension::from_length(100f32),
68 height: taffy::style::Dimension::from_length(100f32),
69 },
70 ..Default::default()
71 },
72 &[node0],
73 )
74 .unwrap();
75 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
76 println!("\nComputed tree:");
77 taffy.print_tree(node);
78 println!();
79 let layout = taffy.layout(node).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
82 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
85 let layout = taffy.layout(node0).unwrap();
86 let Layout { size, location, .. } = layout;
87 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node0, 80f32, size.width);
88 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
89 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
90 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
91}