⎇ 837d03fde9d8a4efa0f4eaf1e8be2fd34a719a50
tests/generated/rounding_inner_node_controversy_vertical.rs
Historia
Quién tocó qué
crudo
Fix 1px wide gaps between adjacent UI nodes (#374)
1#[test]
2fn rounding_inner_node_controversy_vertical() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style {
9 flex_grow: 1f32,
10 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() },
11 ..Default::default()
12 })
13 .unwrap();
14 let node10 = taffy
15 .new_leaf(taffy::style::Style {
16 flex_grow: 1f32,
17 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() },
18 ..Default::default()
19 })
20 .unwrap();
21 let node1 = taffy
22 .new_with_children(
23 taffy::style::Style {
24 flex_direction: taffy::style::FlexDirection::Column,
25 flex_grow: 1f32,
26 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() },
27 ..Default::default()
28 },
29 &[node10],
30 )
31 .unwrap();
32 let node2 = taffy
33 .new_leaf(taffy::style::Style {
34 flex_grow: 1f32,
35 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(10f32), height: auto() },
36 ..Default::default()
37 })
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 flex_direction: taffy::style::FlexDirection::Column,
43 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(320f32) },
44 ..Default::default()
45 },
46 &[node0, node1, node2],
47 )
48 .unwrap();
49 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
50 println!("\nComputed tree:");
51 taffy::debug::print_tree(&taffy, node);
52 println!();
53 let Layout { size, location, .. } = taffy.layout(node).unwrap();
54 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 10f32, size.width);
55 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
58 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
59 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.width);
60 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 107f32, size.height);
61 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
62 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
63 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
64 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.width);
65 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 106f32, size.height);
66 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
67 assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 107f32, location.y);
68 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
69 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.width);
70 assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 106f32, size.height);
71 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
72 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
73 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
74 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, size.width);
75 assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 107f32, size.height);
76 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.x);
77 assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 213f32, location.y);
78}