⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/wrap_column.rs
Historia
Quién tocó qué
crudo
Sort test fixtures and generated tests into folders (#514)
1#[test]
2fn wrap_column() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size {
9 width: taffy::style::Dimension::Length(30f32),
10 height: taffy::style::Dimension::Length(31f32),
11 },
12 ..Default::default()
13 })
14 .unwrap();
15 let node1 = taffy
16 .new_leaf(taffy::style::Style {
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::Length(30f32),
19 height: taffy::style::Dimension::Length(32f32),
20 },
21 ..Default::default()
22 })
23 .unwrap();
24 let node2 = taffy
25 .new_leaf(taffy::style::Style {
26 size: taffy::geometry::Size {
27 width: taffy::style::Dimension::Length(30f32),
28 height: taffy::style::Dimension::Length(33f32),
29 },
30 ..Default::default()
31 })
32 .unwrap();
33 let node3 = taffy
34 .new_leaf(taffy::style::Style {
35 size: taffy::geometry::Size {
36 width: taffy::style::Dimension::Length(30f32),
37 height: taffy::style::Dimension::Length(34f32),
38 },
39 ..Default::default()
40 })
41 .unwrap();
42 let node = taffy
43 .new_with_children(
44 taffy::style::Style {
45 flex_direction: taffy::style::FlexDirection::Column,
46 flex_wrap: taffy::style::FlexWrap::Wrap,
47 size: taffy::geometry::Size {
48 width: taffy::style::Dimension::Length(100f32),
49 height: taffy::style::Dimension::Length(100f32),
50 },
51 ..Default::default()
52 },
53 &[node0, node1, node2, node3],
54 )
55 .unwrap();
56 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
57 println!("\nComputed tree:");
58 taffy::util::print_tree(&taffy, node);
59 println!();
60 let Layout { size, location, .. } = taffy.layout(node).unwrap();
61 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
62 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
63 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
64 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
65 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
66 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
67 assert_eq!(size.height, 31f32, "height of node {:?}. Expected {}. Actual {}", node0, 31f32, size.height);
68 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
69 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
70 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
71 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node1, 30f32, size.width);
72 assert_eq!(size.height, 32f32, "height of node {:?}. Expected {}. Actual {}", node1, 32f32, size.height);
73 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
74 assert_eq!(location.y, 31f32, "y of node {:?}. Expected {}. Actual {}", node1, 31f32, location.y);
75 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
76 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node2, 30f32, size.width);
77 assert_eq!(size.height, 33f32, "height of node {:?}. Expected {}. Actual {}", node2, 33f32, size.height);
78 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
79 assert_eq!(location.y, 63f32, "y of node {:?}. Expected {}. Actual {}", node2, 63f32, location.y);
80 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
81 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node3, 30f32, size.width);
82 assert_eq!(size.height, 34f32, "height of node {:?}. Expected {}. Actual {}", node3, 34f32, size.height);
83 assert_eq!(location.x, 50f32, "x of node {:?}. Expected {}. Actual {}", node3, 50f32, location.x);
84 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y);
85}