⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/flex_shrink_flex_grow_row.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn flex_shrink_flex_grow_row__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: 0f32,
10 flex_shrink: 1f32,
11 size: taffy::geometry::Size {
12 width: taffy::style::Dimension::from_length(500f32),
13 height: taffy::style::Dimension::from_length(100f32),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node1 = taffy
19 .new_leaf(taffy::style::Style {
20 flex_grow: 0f32,
21 flex_shrink: 1f32,
22 size: taffy::geometry::Size {
23 width: taffy::style::Dimension::from_length(500f32),
24 height: taffy::style::Dimension::from_length(100f32),
25 },
26 ..Default::default()
27 })
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 size: taffy::geometry::Size {
33 width: taffy::style::Dimension::from_length(500f32),
34 height: taffy::style::Dimension::from_length(500f32),
35 },
36 ..Default::default()
37 },
38 &[node0, node1],
39 )
40 .unwrap();
41 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
42 println!("\nComputed tree:");
43 taffy.print_tree(node);
44 println!();
45 let layout = taffy.layout(node).unwrap();
46 let Layout { size, location, .. } = layout;
47 assert_eq!(size.width, 500f32, "width of node {:?}. Expected {}. Actual {}", node, 500f32, size.width);
48 assert_eq!(size.height, 500f32, "height of node {:?}. Expected {}. Actual {}", node, 500f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
51 let layout = taffy.layout(node0).unwrap();
52 let Layout { size, location, .. } = layout;
53 assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width);
54 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
57 let layout = taffy.layout(node1).unwrap();
58 let Layout { size, location, .. } = layout;
59 assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width);
60 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
61 assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
63}
64
65#[test]
66#[allow(non_snake_case)]
67fn flex_shrink_flex_grow_row__content_box() {
68 #[allow(unused_imports)]
69 use taffy::{prelude::*, Layout};
70 let mut taffy = crate::new_test_tree();
71 let node0 = taffy
72 .new_leaf(taffy::style::Style {
73 box_sizing: taffy::style::BoxSizing::ContentBox,
74 flex_grow: 0f32,
75 flex_shrink: 1f32,
76 size: taffy::geometry::Size {
77 width: taffy::style::Dimension::from_length(500f32),
78 height: taffy::style::Dimension::from_length(100f32),
79 },
80 ..Default::default()
81 })
82 .unwrap();
83 let node1 = taffy
84 .new_leaf(taffy::style::Style {
85 box_sizing: taffy::style::BoxSizing::ContentBox,
86 flex_grow: 0f32,
87 flex_shrink: 1f32,
88 size: taffy::geometry::Size {
89 width: taffy::style::Dimension::from_length(500f32),
90 height: taffy::style::Dimension::from_length(100f32),
91 },
92 ..Default::default()
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, node1],
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, 250f32, "width of node {:?}. Expected {}. Actual {}", node0, 250f32, size.width);
121 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, 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(node1).unwrap();
125 let Layout { size, location, .. } = layout;
126 assert_eq!(size.width, 250f32, "width of node {:?}. Expected {}. Actual {}", node1, 250f32, size.width);
127 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node1, 100f32, size.height);
128 assert_eq!(location.x, 250f32, "x of node {:?}. Expected {}. Actual {}", node1, 250f32, location.x);
129 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
130}