⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/absolute_layout_child_order.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 absolute_layout_child_order__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 {
10 width: taffy::style::Dimension::from_length(60f32),
11 height: taffy::style::Dimension::from_length(40f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node1 = taffy
17 .new_leaf(taffy::style::Style {
18 position: taffy::style::Position::Absolute,
19 size: taffy::geometry::Size {
20 width: taffy::style::Dimension::from_length(60f32),
21 height: taffy::style::Dimension::from_length(40f32),
22 },
23 ..Default::default()
24 })
25 .unwrap();
26 let node2 = taffy
27 .new_leaf(taffy::style::Style {
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::from_length(60f32),
30 height: taffy::style::Dimension::from_length(40f32),
31 },
32 ..Default::default()
33 })
34 .unwrap();
35 let node = taffy
36 .new_with_children(
37 taffy::style::Style {
38 align_items: Some(taffy::style::AlignItems::Center),
39 justify_content: Some(taffy::style::JustifyContent::Center),
40 size: taffy::geometry::Size {
41 width: taffy::style::Dimension::from_length(110f32),
42 height: taffy::style::Dimension::from_length(100f32),
43 },
44 ..Default::default()
45 },
46 &[node0, node1, node2],
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, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width);
56 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, 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, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width);
62 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
63 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
64 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
65 let layout = taffy.layout(node1).unwrap();
66 let Layout { size, location, .. } = layout;
67 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width);
68 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
69 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node1, 25f32, location.x);
70 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
71 let layout = taffy.layout(node2).unwrap();
72 let Layout { size, location, .. } = layout;
73 assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node2, 55f32, size.width);
74 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
75 assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x);
76 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y);
77}
78
79#[test]
80#[allow(non_snake_case)]
81fn absolute_layout_child_order__content_box() {
82 #[allow(unused_imports)]
83 use taffy::{prelude::*, Layout};
84 let mut taffy = crate::new_test_tree();
85 let node0 = taffy
86 .new_leaf(taffy::style::Style {
87 box_sizing: taffy::style::BoxSizing::ContentBox,
88 size: taffy::geometry::Size {
89 width: taffy::style::Dimension::from_length(60f32),
90 height: taffy::style::Dimension::from_length(40f32),
91 },
92 ..Default::default()
93 })
94 .unwrap();
95 let node1 = taffy
96 .new_leaf(taffy::style::Style {
97 box_sizing: taffy::style::BoxSizing::ContentBox,
98 position: taffy::style::Position::Absolute,
99 size: taffy::geometry::Size {
100 width: taffy::style::Dimension::from_length(60f32),
101 height: taffy::style::Dimension::from_length(40f32),
102 },
103 ..Default::default()
104 })
105 .unwrap();
106 let node2 = taffy
107 .new_leaf(taffy::style::Style {
108 box_sizing: taffy::style::BoxSizing::ContentBox,
109 size: taffy::geometry::Size {
110 width: taffy::style::Dimension::from_length(60f32),
111 height: taffy::style::Dimension::from_length(40f32),
112 },
113 ..Default::default()
114 })
115 .unwrap();
116 let node = taffy
117 .new_with_children(
118 taffy::style::Style {
119 box_sizing: taffy::style::BoxSizing::ContentBox,
120 align_items: Some(taffy::style::AlignItems::Center),
121 justify_content: Some(taffy::style::JustifyContent::Center),
122 size: taffy::geometry::Size {
123 width: taffy::style::Dimension::from_length(110f32),
124 height: taffy::style::Dimension::from_length(100f32),
125 },
126 ..Default::default()
127 },
128 &[node0, node1, node2],
129 )
130 .unwrap();
131 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
132 println!("\nComputed tree:");
133 taffy.print_tree(node);
134 println!();
135 let layout = taffy.layout(node).unwrap();
136 let Layout { size, location, .. } = layout;
137 assert_eq!(size.width, 110f32, "width of node {:?}. Expected {}. Actual {}", node, 110f32, size.width);
138 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
139 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
140 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
141 let layout = taffy.layout(node0).unwrap();
142 let Layout { size, location, .. } = layout;
143 assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node0, 55f32, size.width);
144 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
145 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
146 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node0, 30f32, location.y);
147 let layout = taffy.layout(node1).unwrap();
148 let Layout { size, location, .. } = layout;
149 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node1, 60f32, size.width);
150 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1, 40f32, size.height);
151 assert_eq!(location.x, 25f32, "x of node {:?}. Expected {}. Actual {}", node1, 25f32, location.x);
152 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node1, 30f32, location.y);
153 let layout = taffy.layout(node2).unwrap();
154 let Layout { size, location, .. } = layout;
155 assert_eq!(size.width, 55f32, "width of node {:?}. Expected {}. Actual {}", node2, 55f32, size.width);
156 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node2, 40f32, size.height);
157 assert_eq!(location.x, 55f32, "x of node {:?}. Expected {}. Actual {}", node2, 55f32, location.x);
158 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y);
159}