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