gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 501HTML 254C 19JavaScript 81412 Definiciones

⎇ 0.2.x tests/generated/rounding_flex_basis_flex_shrink_row.rs Rust · 56 líneas · 2.3 KB Historia Quién tocó qué crudo

Rename FlexboxLayout back to Style (#251) 49893a7d9 · Nico Burns ·

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