⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/align_baseline_column.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn align_baseline_column__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(50f32),
11 height: taffy::style::Dimension::from_length(50f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node1 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::from_length(50f32),
20 height: taffy::style::Dimension::from_length(20f32),
21 },
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 align_items: Some(taffy::style::AlignItems::Baseline),
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],
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, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
52 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, 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, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
58 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
60 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
61}
62
63#[test]
64#[allow(non_snake_case)]
65fn align_baseline_column__content_box() {
66 #[allow(unused_imports)]
67 use taffy::{prelude::*, Layout};
68 let mut taffy = crate::new_test_tree();
69 let node0 = taffy
70 .new_leaf(taffy::style::Style {
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 size: taffy::geometry::Size {
73 width: taffy::style::Dimension::from_length(50f32),
74 height: taffy::style::Dimension::from_length(50f32),
75 },
76 ..Default::default()
77 })
78 .unwrap();
79 let node1 = taffy
80 .new_leaf(taffy::style::Style {
81 box_sizing: taffy::style::BoxSizing::ContentBox,
82 size: taffy::geometry::Size {
83 width: taffy::style::Dimension::from_length(50f32),
84 height: taffy::style::Dimension::from_length(20f32),
85 },
86 ..Default::default()
87 })
88 .unwrap();
89 let node = taffy
90 .new_with_children(
91 taffy::style::Style {
92 box_sizing: taffy::style::BoxSizing::ContentBox,
93 flex_direction: taffy::style::FlexDirection::Column,
94 align_items: Some(taffy::style::AlignItems::Baseline),
95 size: taffy::geometry::Size {
96 width: taffy::style::Dimension::from_length(100f32),
97 height: taffy::style::Dimension::from_length(100f32),
98 },
99 ..Default::default()
100 },
101 &[node0, node1],
102 )
103 .unwrap();
104 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
105 println!("\nComputed tree:");
106 taffy.print_tree(node);
107 println!();
108 let layout = taffy.layout(node).unwrap();
109 let Layout { size, location, .. } = layout;
110 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
111 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
112 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
113 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
114 let layout = taffy.layout(node0).unwrap();
115 let Layout { size, location, .. } = layout;
116 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
117 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
118 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
119 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
120 let layout = taffy.layout(node1).unwrap();
121 let Layout { size, location, .. } = layout;
122 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
123 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
124 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
125 assert_eq!(location.y, 50f32, "y of node {:?}. Expected {}. Actual {}", node1, 50f32, location.y);
126}