⎇ b746ac4f346dde8a2b6f85d3a428c02a2342f099
tests/generated/flex/undefined_width_with_min_max.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn undefined_width_with_min_max__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() },
10 max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
11 ..Default::default()
12 })
13 .unwrap();
14 let node = taffy
15 .new_with_children(
16 taffy::style::Style {
17 flex_direction: taffy::style::FlexDirection::Column,
18 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) },
19 ..Default::default()
20 },
21 &[node0],
22 )
23 .unwrap();
24 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
25 println!("\nComputed tree:");
26 taffy.print_tree(node);
27 println!();
28 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
29 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
30 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
31 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
32 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
33 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
34 #[cfg(feature = "content_size")]
35 assert_eq!(
36 layout.scroll_width(),
37 0f32,
38 "scroll_width of node {:?}. Expected {}. Actual {}",
39 node,
40 0f32,
41 layout.scroll_width()
42 );
43 #[cfg(feature = "content_size")]
44 assert_eq!(
45 layout.scroll_height(),
46 0f32,
47 "scroll_height of node {:?}. Expected {}. Actual {}",
48 node,
49 0f32,
50 layout.scroll_height()
51 );
52 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
53 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
54 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
55 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
58 #[cfg(feature = "content_size")]
59 assert_eq!(
60 layout.scroll_width(),
61 0f32,
62 "scroll_width of node {:?}. Expected {}. Actual {}",
63 node0,
64 0f32,
65 layout.scroll_width()
66 );
67 #[cfg(feature = "content_size")]
68 assert_eq!(
69 layout.scroll_height(),
70 0f32,
71 "scroll_height of node {:?}. Expected {}. Actual {}",
72 node0,
73 0f32,
74 layout.scroll_height()
75 );
76}
77
78#[test]
79#[allow(non_snake_case)]
80fn undefined_width_with_min_max__content_box() {
81 #[allow(unused_imports)]
82 use taffy::{prelude::*, tree::Layout, TaffyTree};
83 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
84 let node0 = taffy
85 .new_leaf(taffy::style::Style {
86 box_sizing: taffy::style::BoxSizing::ContentBox,
87 min_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(0f32), height: auto() },
88 max_size: taffy::geometry::Size { width: taffy::style::Dimension::Length(100f32), height: auto() },
89 ..Default::default()
90 })
91 .unwrap();
92 let node = taffy
93 .new_with_children(
94 taffy::style::Style {
95 box_sizing: taffy::style::BoxSizing::ContentBox,
96 flex_direction: taffy::style::FlexDirection::Column,
97 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(50f32) },
98 ..Default::default()
99 },
100 &[node0],
101 )
102 .unwrap();
103 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
104 println!("\nComputed tree:");
105 taffy.print_tree(node);
106 println!();
107 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
108 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
109 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
110 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
111 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
112 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
113 #[cfg(feature = "content_size")]
114 assert_eq!(
115 layout.scroll_width(),
116 0f32,
117 "scroll_width of node {:?}. Expected {}. Actual {}",
118 node,
119 0f32,
120 layout.scroll_width()
121 );
122 #[cfg(feature = "content_size")]
123 assert_eq!(
124 layout.scroll_height(),
125 0f32,
126 "scroll_height of node {:?}. Expected {}. Actual {}",
127 node,
128 0f32,
129 layout.scroll_height()
130 );
131 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
132 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
133 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
134 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, 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 #[cfg(feature = "content_size")]
138 assert_eq!(
139 layout.scroll_width(),
140 0f32,
141 "scroll_width of node {:?}. Expected {}. Actual {}",
142 node0,
143 0f32,
144 layout.scroll_width()
145 );
146 #[cfg(feature = "content_size")]
147 assert_eq!(
148 layout.scroll_height(),
149 0f32,
150 "scroll_height of node {:?}. Expected {}. Actual {}",
151 node0,
152 0f32,
153 layout.scroll_height()
154 );
155}