⎇ e8253b1ae8ad9e95777144ce91aa6fb1ec8d4e32
tests/generated/rounding_fractial_input_4.rs
History
Who touched what
raw
Fix 1px wide gaps between adjacent UI nodes (#374)
1#[test]
2fn rounding_fractial_input_4() {
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 flex_basis: taffy::style::Dimension::Points(50f32),
11 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(20f32) },
12 ..Default::default()
13 })
14 .unwrap();
15 let node1 = taffy
16 .new_leaf(taffy::style::Style {
17 flex_grow: 1f32,
18 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
19 ..Default::default()
20 })
21 .unwrap();
22 let node2 = taffy
23 .new_leaf(taffy::style::Style {
24 flex_grow: 1f32,
25 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
26 ..Default::default()
27 })
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 flex_direction: taffy::style::FlexDirection::Column,
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::Points(100f32),
35 height: taffy::style::Dimension::Points(113.4f32),
36 },
37 ..Default::default()
38 },
39 &[node0, node1, node2],
40 )
41 .unwrap();
42 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
43 println!("\nComputed tree:");
44 taffy::debug::print_tree(&taffy, node);
45 println!();
46 let Layout { size, location, .. } = taffy.layout(node).unwrap();
47 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 100f32, size.width);
48 assert_eq!(size.height, 113f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 113f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
51 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
52 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 100f32, size.width);
53 assert_eq!(size.height, 64f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 64f32, size.height);
54 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
55 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
56 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
57 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 100f32, size.width);
58 assert_eq!(size.height, 25f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 25f32, size.height);
59 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.x);
60 assert_eq!(location.y, 64f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 64f32, location.y);
61 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
62 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node2.data(), 100f32, size.width);
63 assert_eq!(size.height, 24f32, "height of node {:?}. Expected {}. Actual {}", node2.data(), 24f32, size.height);
64 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2.data(), 0f32, location.x);
65 assert_eq!(location.y, 89f32, "y of node {:?}. Expected {}. Actual {}", node2.data(), 89f32, location.y);
66}