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