⎇ direction-floats
tests/generated/flex/flex_wrap_reverse_direction_rtl.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
add block layout & inherited fixtures, remove unused `flip` function
1#[test]
2#[allow(non_snake_case)]
3fn flex_wrap_reverse_direction_rtl__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 {
10 width: taffy::style::Dimension::from_length(40f32),
11 height: taffy::style::Dimension::from_length(20f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node1 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::from_length(40f32),
20 height: taffy::style::Dimension::from_length(20f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node2 = taffy
26 .new_leaf(taffy::style::Style {
27 size: taffy::geometry::Size {
28 width: taffy::style::Dimension::from_length(40f32),
29 height: taffy::style::Dimension::from_length(20f32),
30 },
31 ..Default::default()
32 })
33 .unwrap();
34 let node = taffy
35 .new_with_children(
36 taffy::style::Style {
37 direction: taffy::style::Direction::Rtl,
38 flex_wrap: taffy::style::FlexWrap::WrapReverse,
39 size: taffy::geometry::Size {
40 width: taffy::style::Dimension::from_length(100f32),
41 height: taffy::style::Dimension::from_length(100f32),
42 },
43 ..Default::default()
44 },
45 &[node0, node1, node2],
46 )
47 .unwrap();
48 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
49 println!("\nComputed tree:");
50 taffy.print_tree(node);
51 println!();
52 let layout = taffy.layout(node).unwrap();
53 let Layout { size, location, .. } = layout;
54 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
55 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
58 let layout = taffy.layout(node0).unwrap();
59 let Layout { size, location, .. } = layout;
60 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
61 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
62 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
63 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
64 let layout = taffy.layout(node1).unwrap();
65 let Layout { size, location, .. } = layout;
66 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
67 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
68 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x);
69 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y);
70 let layout = taffy.layout(node2).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
73 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
74 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
75 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y);
76}
77
78#[test]
79#[allow(non_snake_case)]
80fn flex_wrap_reverse_direction_rtl__content_box() {
81 #[allow(unused_imports)]
82 use taffy::{prelude::*, Layout};
83 let mut taffy = crate::new_test_tree();
84 let node0 = taffy
85 .new_leaf(taffy::style::Style {
86 box_sizing: taffy::style::BoxSizing::ContentBox,
87 size: taffy::geometry::Size {
88 width: taffy::style::Dimension::from_length(40f32),
89 height: taffy::style::Dimension::from_length(20f32),
90 },
91 ..Default::default()
92 })
93 .unwrap();
94 let node1 = taffy
95 .new_leaf(taffy::style::Style {
96 box_sizing: taffy::style::BoxSizing::ContentBox,
97 size: taffy::geometry::Size {
98 width: taffy::style::Dimension::from_length(40f32),
99 height: taffy::style::Dimension::from_length(20f32),
100 },
101 ..Default::default()
102 })
103 .unwrap();
104 let node2 = taffy
105 .new_leaf(taffy::style::Style {
106 box_sizing: taffy::style::BoxSizing::ContentBox,
107 size: taffy::geometry::Size {
108 width: taffy::style::Dimension::from_length(40f32),
109 height: taffy::style::Dimension::from_length(20f32),
110 },
111 ..Default::default()
112 })
113 .unwrap();
114 let node = taffy
115 .new_with_children(
116 taffy::style::Style {
117 box_sizing: taffy::style::BoxSizing::ContentBox,
118 direction: taffy::style::Direction::Rtl,
119 flex_wrap: taffy::style::FlexWrap::WrapReverse,
120 size: taffy::geometry::Size {
121 width: taffy::style::Dimension::from_length(100f32),
122 height: taffy::style::Dimension::from_length(100f32),
123 },
124 ..Default::default()
125 },
126 &[node0, node1, node2],
127 )
128 .unwrap();
129 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
130 println!("\nComputed tree:");
131 taffy.print_tree(node);
132 println!();
133 let layout = taffy.layout(node).unwrap();
134 let Layout { size, location, .. } = layout;
135 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
136 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
137 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
138 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
139 let layout = taffy.layout(node0).unwrap();
140 let Layout { size, location, .. } = layout;
141 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0, 40f32, size.width);
142 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
143 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
144 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node0, 80f32, location.y);
145 let layout = taffy.layout(node1).unwrap();
146 let Layout { size, location, .. } = layout;
147 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node1, 40f32, size.width);
148 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node1, 20f32, size.height);
149 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node1, 20f32, location.x);
150 assert_eq!(location.y, 80f32, "y of node {:?}. Expected {}. Actual {}", node1, 80f32, location.y);
151 let layout = taffy.layout(node2).unwrap();
152 let Layout { size, location, .. } = layout;
153 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node2, 40f32, size.width);
154 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node2, 20f32, size.height);
155 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node2, 60f32, location.x);
156 assert_eq!(location.y, 30f32, "y of node {:?}. Expected {}. Actual {}", node2, 30f32, location.y);
157}