⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/undefined_height_with_min_max.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn undefined_height_with_min_max__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 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) },
10 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
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: taffy::style::Dimension::from_length(320f32), height: auto() },
19 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) },
20 ..Default::default()
21 },
22 &[node0],
23 )
24 .unwrap();
25 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
26 println!("\nComputed tree:");
27 taffy.print_tree(node);
28 println!();
29 let layout = taffy.layout(node).unwrap();
30 let Layout { size, location, .. } = layout;
31 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
32 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
35 let layout = taffy.layout(node0).unwrap();
36 let Layout { size, location, .. } = layout;
37 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width);
38 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
41}
42
43#[test]
44#[allow(non_snake_case)]
45fn undefined_height_with_min_max__content_box() {
46 #[allow(unused_imports)]
47 use taffy::{prelude::*, Layout};
48 let mut taffy = crate::new_test_tree();
49 let node0 = taffy
50 .new_leaf(taffy::style::Style {
51 box_sizing: taffy::style::BoxSizing::ContentBox,
52 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) },
53 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
54 ..Default::default()
55 })
56 .unwrap();
57 let node = taffy
58 .new_with_children(
59 taffy::style::Style {
60 box_sizing: taffy::style::BoxSizing::ContentBox,
61 flex_direction: taffy::style::FlexDirection::Column,
62 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(320f32), height: auto() },
63 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(0f32) },
64 ..Default::default()
65 },
66 &[node0],
67 )
68 .unwrap();
69 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
70 println!("\nComputed tree:");
71 taffy.print_tree(node);
72 println!();
73 let layout = taffy.layout(node).unwrap();
74 let Layout { size, location, .. } = layout;
75 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
76 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
79 let layout = taffy.layout(node0).unwrap();
80 let Layout { size, location, .. } = layout;
81 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node0, 320f32, size.width);
82 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
83 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
85}