⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/justify_content_column_flex_start.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn justify_content_column_flex_start__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 { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
10 ..Default::default()
11 })
12 .unwrap();
13 let node1 = taffy
14 .new_leaf(taffy::style::Style {
15 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
16 ..Default::default()
17 })
18 .unwrap();
19 let node2 = taffy
20 .new_leaf(taffy::style::Style {
21 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
22 ..Default::default()
23 })
24 .unwrap();
25 let node = taffy
26 .new_with_children(
27 taffy::style::Style {
28 flex_direction: taffy::style::FlexDirection::Column,
29 justify_content: Some(taffy::style::JustifyContent::FlexStart),
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::from_length(100f32),
32 height: taffy::style::Dimension::from_length(100f32),
33 },
34 ..Default::default()
35 },
36 &[node0, node1, node2],
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, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, 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, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, 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(node1).unwrap();
56 let Layout { size, location, .. } = layout;
57 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
58 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
60 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
61 let layout = taffy.layout(node2).unwrap();
62 let Layout { size, location, .. } = layout;
63 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width);
64 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
66 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y);
67}
68
69#[test]
70#[allow(non_snake_case)]
71fn justify_content_column_flex_start__content_box() {
72 #[allow(unused_imports)]
73 use taffy::{prelude::*, Layout};
74 let mut taffy = crate::new_test_tree();
75 let node0 = taffy
76 .new_leaf(taffy::style::Style {
77 box_sizing: taffy::style::BoxSizing::ContentBox,
78 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
79 ..Default::default()
80 })
81 .unwrap();
82 let node1 = taffy
83 .new_leaf(taffy::style::Style {
84 box_sizing: taffy::style::BoxSizing::ContentBox,
85 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
86 ..Default::default()
87 })
88 .unwrap();
89 let node2 = taffy
90 .new_leaf(taffy::style::Style {
91 box_sizing: taffy::style::BoxSizing::ContentBox,
92 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(10f32) },
93 ..Default::default()
94 })
95 .unwrap();
96 let node = taffy
97 .new_with_children(
98 taffy::style::Style {
99 box_sizing: taffy::style::BoxSizing::ContentBox,
100 flex_direction: taffy::style::FlexDirection::Column,
101 justify_content: Some(taffy::style::JustifyContent::FlexStart),
102 size: taffy::geometry::Size {
103 width: taffy::style::Dimension::from_length(100f32),
104 height: taffy::style::Dimension::from_length(100f32),
105 },
106 ..Default::default()
107 },
108 &[node0, node1, node2],
109 )
110 .unwrap();
111 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
112 println!("\nComputed tree:");
113 taffy.print_tree(node);
114 println!();
115 let layout = taffy.layout(node).unwrap();
116 let Layout { size, location, .. } = layout;
117 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
118 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
119 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
120 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
121 let layout = taffy.layout(node0).unwrap();
122 let Layout { size, location, .. } = layout;
123 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
124 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
125 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
126 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
127 let layout = taffy.layout(node1).unwrap();
128 let Layout { size, location, .. } = layout;
129 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
130 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1, 10f32, size.height);
131 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
132 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
133 let layout = taffy.layout(node2).unwrap();
134 let Layout { size, location, .. } = layout;
135 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2, 100f32, size.width);
136 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2, 10f32, size.height);
137 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
138 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node2, 20f32, location.y);
139}