gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 1086HTML 1018Markdown 12TOML 84406 Definiciones

⎇ 568f643327ec6b4879df0087def7f4e66b6acafb tests/generated/rounding_inner_node_controversy_combined.rs Rust · 119 líneas · 6.7 KB Historia Quién tocó qué crudo

Rename `Points`/`points` to `Length`/`length` in many APIs (#459) 55abeaf2e · Simon Sapin ·

1#[test]
2fn rounding_inner_node_controversy_combined() {
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            flex_grow: 1f32,
9            size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
10            ..Default::default()
11        })
12        .unwrap();
13    let node10 = taffy
14        .new_leaf(taffy::style::Style {
15            flex_grow: 1f32,
16            size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
17            ..Default::default()
18        })
19        .unwrap();
20    let node110 = taffy
21        .new_leaf(taffy::style::Style {
22            flex_grow: 1f32,
23            size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
24            ..Default::default()
25        })
26        .unwrap();
27    let node11 = taffy
28        .new_with_children(
29            taffy::style::Style {
30                flex_direction: taffy::style::FlexDirection::Column,
31                flex_grow: 1f32,
32                size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
33                ..Default::default()
34            },
35            &[node110],
36        )
37        .unwrap();
38    let node12 = taffy
39        .new_leaf(taffy::style::Style {
40            flex_grow: 1f32,
41            size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
42            ..Default::default()
43        })
44        .unwrap();
45    let node1 = taffy
46        .new_with_children(
47            taffy::style::Style {
48                flex_direction: taffy::style::FlexDirection::Column,
49                flex_grow: 1f32,
50                size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
51                ..Default::default()
52            },
53            &[node10, node11, node12],
54        )
55        .unwrap();
56    let node2 = taffy
57        .new_leaf(taffy::style::Style {
58            flex_grow: 1f32,
59            size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Percent(1f32) },
60            ..Default::default()
61        })
62        .unwrap();
63    let node = taffy
64        .new_with_children(
65            taffy::style::Style {
66                size: taffy::geometry::Size {
67                    width: taffy::style::Dimension::Length(640f32),
68                    height: taffy::style::Dimension::Length(320f32),
69                },
70                ..Default::default()
71            },
72            &[node0, node1, node2],
73        )
74        .unwrap();
75    taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
76    println!("\nComputed tree:");
77    taffy::util::print_tree(&taffy, node);
78    println!();
79    let Layout { size, location, .. } = taffy.layout(node).unwrap();
80    assert_eq!(size.width, 640f32, "width of node {:?}. Expected {}. Actual {}", node, 640f32, size.width);
81    assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
82    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
83    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
84    let Layout { size, location, .. } = taffy.layout(node0).unwrap();
85    assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node0, 213f32, size.width);
86    assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node0, 320f32, size.height);
87    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
88    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
89    let Layout { size, location, .. } = taffy.layout(node1).unwrap();
90    assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node1, 214f32, size.width);
91    assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node1, 320f32, size.height);
92    assert_eq!(location.x, 213f32, "x of node {:?}. Expected {}. Actual {}", node1, 213f32, location.x);
93    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
94    let Layout { size, location, .. } = taffy.layout(node10).unwrap();
95    assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node10, 214f32, size.width);
96    assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node10, 107f32, size.height);
97    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node10, 0f32, location.x);
98    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node10, 0f32, location.y);
99    let Layout { size, location, .. } = taffy.layout(node11).unwrap();
100    assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node11, 214f32, size.width);
101    assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node11, 106f32, size.height);
102    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node11, 0f32, location.x);
103    assert_eq!(location.y, 107f32, "y of node {:?}. Expected {}. Actual {}", node11, 107f32, location.y);
104    let Layout { size, location, .. } = taffy.layout(node110).unwrap();
105    assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node110, 214f32, size.width);
106    assert_eq!(size.height, 106f32, "height of node {:?}. Expected {}. Actual {}", node110, 106f32, size.height);
107    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node110, 0f32, location.x);
108    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node110, 0f32, location.y);
109    let Layout { size, location, .. } = taffy.layout(node12).unwrap();
110    assert_eq!(size.width, 214f32, "width of node {:?}. Expected {}. Actual {}", node12, 214f32, size.width);
111    assert_eq!(size.height, 107f32, "height of node {:?}. Expected {}. Actual {}", node12, 107f32, size.height);
112    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node12, 0f32, location.x);
113    assert_eq!(location.y, 213f32, "y of node {:?}. Expected {}. Actual {}", node12, 213f32, location.y);
114    let Layout { size, location, .. } = taffy.layout(node2).unwrap();
115    assert_eq!(size.width, 213f32, "width of node {:?}. Expected {}. Actual {}", node2, 213f32, size.width);
116    assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node2, 320f32, size.height);
117    assert_eq!(location.x, 427f32, "x of node {:?}. Expected {}. Actual {}", node2, 427f32, location.x);
118    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
119}