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