⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/align_content_stretch_row_wrap.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_content_stretch_row_wrap__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::from_length(50f32),
11 height: taffy::style::Dimension::from_length(150f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
20 ..Default::default()
21 },
22 &[node00],
23 )
24 .unwrap();
25 let node = taffy
26 .new_with_children(
27 taffy::style::Style {
28 flex_wrap: taffy::style::FlexWrap::Wrap,
29 align_content: Some(taffy::style::AlignContent::Stretch),
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::from_length(150f32),
32 height: taffy::style::Dimension::from_length(100f32),
33 },
34 ..Default::default()
35 },
36 &[node0],
37 )
38 .unwrap();
39 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
40 println!("\nComputed tree:");
41 taffy.print_tree(node);
42 println!();
43 let layout = taffy.layout(node).unwrap();
44 let Layout { size, location, .. } = layout;
45 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
46 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
47 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
48 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
49 let layout = taffy.layout(node0).unwrap();
50 let Layout { size, location, .. } = layout;
51 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
52 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height);
53 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
54 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
55 let layout = taffy.layout(node00).unwrap();
56 let Layout { size, location, .. } = layout;
57 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
58 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
60 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
61}
62
63#[test]
64#[allow(non_snake_case)]
65fn align_content_stretch_row_wrap__content_box() {
66 #[allow(unused_imports)]
67 use taffy::{prelude::*, Layout};
68 let mut taffy = crate::new_test_tree();
69 let node00 = taffy
70 .new_leaf(taffy::style::Style {
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 size: taffy::geometry::Size {
73 width: taffy::style::Dimension::from_length(50f32),
74 height: taffy::style::Dimension::from_length(150f32),
75 },
76 ..Default::default()
77 })
78 .unwrap();
79 let node0 = taffy
80 .new_with_children(
81 taffy::style::Style {
82 box_sizing: taffy::style::BoxSizing::ContentBox,
83 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
84 ..Default::default()
85 },
86 &[node00],
87 )
88 .unwrap();
89 let node = taffy
90 .new_with_children(
91 taffy::style::Style {
92 box_sizing: taffy::style::BoxSizing::ContentBox,
93 flex_wrap: taffy::style::FlexWrap::Wrap,
94 align_content: Some(taffy::style::AlignContent::Stretch),
95 size: taffy::geometry::Size {
96 width: taffy::style::Dimension::from_length(150f32),
97 height: taffy::style::Dimension::from_length(100f32),
98 },
99 ..Default::default()
100 },
101 &[node0],
102 )
103 .unwrap();
104 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
105 println!("\nComputed tree:");
106 taffy.print_tree(node);
107 println!();
108 let layout = taffy.layout(node).unwrap();
109 let Layout { size, location, .. } = layout;
110 assert_eq!(size.width, 150f32, "width of node {:?}. Expected {}. Actual {}", node, 150f32, size.width);
111 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
112 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
113 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
114 let layout = taffy.layout(node0).unwrap();
115 let Layout { size, location, .. } = layout;
116 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
117 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node0, 150f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
120 let layout = taffy.layout(node00).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node00, 50f32, size.width);
123 assert_eq!(size.height, 150f32, "height of node {:?}. Expected {}. Actual {}", node00, 150f32, size.height);
124 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
125 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
126}