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