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