gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Definiciones

⎇ a1e91740880b61f1c39c9114b628ff09655141a9 tests/generated/flex_direction_row_no_width.rs Rust · 57 líneas · 2.3 KB Historia Quién tocó qué crudo

Rename generated files (#80) 78c5e05ef · Andreas Weibye ·

1#[test]
2fn flex_direction_row_no_width() {
3    let mut sprawl = sprawl::Sprawl::new();
4    let node0 = sprawl
5        .new_node(
6            sprawl::style::Style {
7                size: sprawl::geometry::Size { width: sprawl::style::Dimension::Points(10f32), ..Default::default() },
8                ..Default::default()
9            },
10            &[],
11        )
12        .unwrap();
13    let node1 = sprawl
14        .new_node(
15            sprawl::style::Style {
16                size: sprawl::geometry::Size { width: sprawl::style::Dimension::Points(10f32), ..Default::default() },
17                ..Default::default()
18            },
19            &[],
20        )
21        .unwrap();
22    let node2 = sprawl
23        .new_node(
24            sprawl::style::Style {
25                size: sprawl::geometry::Size { width: sprawl::style::Dimension::Points(10f32), ..Default::default() },
26                ..Default::default()
27            },
28            &[],
29        )
30        .unwrap();
31    let node = sprawl
32        .new_node(
33            sprawl::style::Style {
34                size: sprawl::geometry::Size { height: sprawl::style::Dimension::Points(100f32), ..Default::default() },
35                ..Default::default()
36            },
37            &[node0, node1, node2],
38        )
39        .unwrap();
40    sprawl.compute_layout(node, sprawl::geometry::Size::undefined()).unwrap();
41    assert_eq!(sprawl.layout(node).unwrap().size.width, 30f32);
42    assert_eq!(sprawl.layout(node).unwrap().size.height, 100f32);
43    assert_eq!(sprawl.layout(node).unwrap().location.x, 0f32);
44    assert_eq!(sprawl.layout(node).unwrap().location.y, 0f32);
45    assert_eq!(sprawl.layout(node0).unwrap().size.width, 10f32);
46    assert_eq!(sprawl.layout(node0).unwrap().size.height, 100f32);
47    assert_eq!(sprawl.layout(node0).unwrap().location.x, 0f32);
48    assert_eq!(sprawl.layout(node0).unwrap().location.y, 0f32);
49    assert_eq!(sprawl.layout(node1).unwrap().size.width, 10f32);
50    assert_eq!(sprawl.layout(node1).unwrap().size.height, 100f32);
51    assert_eq!(sprawl.layout(node1).unwrap().location.x, 10f32);
52    assert_eq!(sprawl.layout(node1).unwrap().location.y, 0f32);
53    assert_eq!(sprawl.layout(node2).unwrap().size.width, 10f32);
54    assert_eq!(sprawl.layout(node2).unwrap().size.height, 100f32);
55    assert_eq!(sprawl.layout(node2).unwrap().location.x, 20f32);
56    assert_eq!(sprawl.layout(node2).unwrap().location.y, 0f32);
57}