⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/align_content_center_single_line_negative_space.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 align_content_center_single_line_negative_space__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 flex_shrink: 0f32,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::from_percent(0.8f32),
12 height: taffy::style::Dimension::from_length(60f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node0 = taffy
18 .new_with_children(
19 taffy::style::Style {
20 display: taffy::style::Display::Flex,
21 align_content: Some(taffy::style::AlignContent::Center),
22 justify_content: Some(taffy::style::JustifyContent::Center),
23 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
24 ..Default::default()
25 },
26 &[node00],
27 )
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 display: taffy::style::Display::Flex,
33 flex_direction: taffy::style::FlexDirection::Column,
34 size: taffy::geometry::Size {
35 width: taffy::style::Dimension::from_length(320f32),
36 height: taffy::style::Dimension::from_length(320f32),
37 },
38 border: taffy::geometry::Rect {
39 left: length(60f32),
40 right: length(60f32),
41 top: length(60f32),
42 bottom: length(60f32),
43 },
44 ..Default::default()
45 },
46 &[node0],
47 )
48 .unwrap();
49 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
50 println!("\nComputed tree:");
51 taffy.print_tree(node);
52 println!();
53 let layout = taffy.layout(node).unwrap();
54 let Layout { size, location, .. } = layout;
55 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
56 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
57 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
58 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
59 let layout = taffy.layout(node0).unwrap();
60 let Layout { size, location, .. } = layout;
61 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
62 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
63 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
64 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
65 let layout = taffy.layout(node00).unwrap();
66 let Layout { size, location, .. } = layout;
67 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
68 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height);
69 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
70 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
71}
72
73#[test]
74#[allow(non_snake_case)]
75fn align_content_center_single_line_negative_space__content_box() {
76 #[allow(unused_imports)]
77 use taffy::{prelude::*, Layout};
78 let mut taffy = crate::new_test_tree();
79 let node00 = taffy
80 .new_leaf(taffy::style::Style {
81 box_sizing: taffy::style::BoxSizing::ContentBox,
82 flex_shrink: 0f32,
83 size: taffy::geometry::Size {
84 width: taffy::style::Dimension::from_percent(0.8f32),
85 height: taffy::style::Dimension::from_length(60f32),
86 },
87 ..Default::default()
88 })
89 .unwrap();
90 let node0 = taffy
91 .new_with_children(
92 taffy::style::Style {
93 display: taffy::style::Display::Flex,
94 box_sizing: taffy::style::BoxSizing::ContentBox,
95 align_content: Some(taffy::style::AlignContent::Center),
96 justify_content: Some(taffy::style::JustifyContent::Center),
97 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
98 ..Default::default()
99 },
100 &[node00],
101 )
102 .unwrap();
103 let node = taffy
104 .new_with_children(
105 taffy::style::Style {
106 display: taffy::style::Display::Flex,
107 box_sizing: taffy::style::BoxSizing::ContentBox,
108 flex_direction: taffy::style::FlexDirection::Column,
109 size: taffy::geometry::Size {
110 width: taffy::style::Dimension::from_length(320f32),
111 height: taffy::style::Dimension::from_length(320f32),
112 },
113 border: taffy::geometry::Rect {
114 left: length(60f32),
115 right: length(60f32),
116 top: length(60f32),
117 bottom: length(60f32),
118 },
119 ..Default::default()
120 },
121 &[node0],
122 )
123 .unwrap();
124 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
125 println!("\nComputed tree:");
126 taffy.print_tree(node);
127 println!();
128 let layout = taffy.layout(node).unwrap();
129 let Layout { size, location, .. } = layout;
130 assert_eq!(size.width, 440f32, "width of node {:?}. Expected {}. Actual {}", node, 440f32, size.width);
131 assert_eq!(size.height, 440f32, "height of node {:?}. Expected {}. Actual {}", node, 440f32, size.height);
132 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
133 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
134 let layout = taffy.layout(node0).unwrap();
135 let Layout { size, location, .. } = layout;
136 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width);
137 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
138 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
139 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
140 let layout = taffy.layout(node00).unwrap();
141 let Layout { size, location, .. } = layout;
142 assert_eq!(size.width, 256f32, "width of node {:?}. Expected {}. Actual {}", node00, 256f32, size.width);
143 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height);
144 assert_eq!(location.x, 32f32, "x of node {:?}. Expected {}. Actual {}", node00, 32f32, location.x);
145 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
146}