⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/flex_root_ignored.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn flex_root_ignored__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 flex_grow: 1f32,
10 flex_basis: taffy::style::Dimension::from_length(200f32),
11 ..Default::default()
12 })
13 .unwrap();
14 let node1 = taffy
15 .new_leaf(taffy::style::Style {
16 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
17 ..Default::default()
18 })
19 .unwrap();
20 let node = taffy
21 .new_with_children(
22 taffy::style::Style {
23 flex_direction: taffy::style::FlexDirection::Column,
24 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
25 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
26 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) },
27 ..Default::default()
28 },
29 &[node0, node1],
30 )
31 .unwrap();
32 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
33 println!("\nComputed tree:");
34 taffy.print_tree(node);
35 println!();
36 let layout = taffy.layout(node).unwrap();
37 let Layout { size, location, .. } = layout;
38 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
39 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
42 let layout = taffy.layout(node0).unwrap();
43 let Layout { size, location, .. } = layout;
44 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
45 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height);
46 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
47 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
48 let layout = taffy.layout(node1).unwrap();
49 let Layout { size, location, .. } = layout;
50 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
51 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
52 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
53 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y);
54}
55
56#[test]
57#[allow(non_snake_case)]
58fn flex_root_ignored__content_box() {
59 #[allow(unused_imports)]
60 use taffy::{prelude::*, Layout};
61 let mut taffy = crate::new_test_tree();
62 let node0 = taffy
63 .new_leaf(taffy::style::Style {
64 box_sizing: taffy::style::BoxSizing::ContentBox,
65 flex_grow: 1f32,
66 flex_basis: taffy::style::Dimension::from_length(200f32),
67 ..Default::default()
68 })
69 .unwrap();
70 let node1 = taffy
71 .new_leaf(taffy::style::Style {
72 box_sizing: taffy::style::BoxSizing::ContentBox,
73 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
74 ..Default::default()
75 })
76 .unwrap();
77 let node = taffy
78 .new_with_children(
79 taffy::style::Style {
80 box_sizing: taffy::style::BoxSizing::ContentBox,
81 flex_direction: taffy::style::FlexDirection::Column,
82 size: taffy::geometry::Size { width: taffy::style::Dimension::from_length(100f32), height: auto() },
83 min_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(100f32) },
84 max_size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::from_length(500f32) },
85 ..Default::default()
86 },
87 &[node0, node1],
88 )
89 .unwrap();
90 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
91 println!("\nComputed tree:");
92 taffy.print_tree(node);
93 println!();
94 let layout = taffy.layout(node).unwrap();
95 let Layout { size, location, .. } = layout;
96 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
97 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
98 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
99 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
100 let layout = taffy.layout(node0).unwrap();
101 let Layout { size, location, .. } = layout;
102 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
103 assert_eq!(size.height, 200f32, "height of node {:?}. Expected {}. Actual {}", node0, 200f32, size.height);
104 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
105 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
106 let layout = taffy.layout(node1).unwrap();
107 let Layout { size, location, .. } = layout;
108 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1, 100f32, size.width);
109 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
110 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
111 assert_eq!(location.y, 200f32, "y of node {:?}. Expected {}. Actual {}", node1, 200f32, location.y);
112}