⎇ e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32
tests/generated/rounding_inner_node_controversy_horizontal.rs
Historia
Quién tocó qué
crudo
Fix 1px wide gaps between adjacent UI nodes (#374)
1#[test]
2fn rounding_inner_node_controversy_horizontal() {
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: auto(), height: taffy::style::Dimension::Points(10f32) },
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: auto(), height: taffy::style::Dimension::Points(10f32) },
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: auto(), height: taffy::style::Dimension::Points(10f32) },
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: auto(), height: taffy::style::Dimension::Points(10f32) },
36 ..Default::default()
37 })
38 .unwrap();
39 let node = taffy
40 .new_with_children(
41 taffy::style::Style {
42 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(320f32), height: auto() },
43 ..Default::default()
44 },
45 &[node0, node1, node2],
46 )
47 .unwrap();
48 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
49 println!("\nComputed tree:");
50 taffy::debug::print_tree(&taffy, node);
51 println!();
52 let Layout { size, location, .. } = taffy.layout(node).unwrap();
53 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
54 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 10f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
57 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
58 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 107f32, size.width);
59 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
61 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
62 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
63 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 106f32, size.width);
64 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 10f32, size.height);
65 assert_eq!(location.x, 107f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 107f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
67 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
68 assert_eq!(size.width, 106f32, "width of node {:?}. Expected {}. Actual {}", node10.data(), 106f32, size.width);
69 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node10.data(), 10f32, size.height);
70 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10.data(), 0f32, location.y);
72 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
73 assert_eq!(size.width, 107f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 107f32, size.width);
74 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 10f32, size.height);
75 assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 213f32, location.x);
76 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.y);
77}