tawasuyu

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 707HTML 660Markdown 12TOML 62344 Definiciones

⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f tests/generated/flex/measure_root.rs Rust · 47 líneas · 2.2 KB Historia Quién tocó qué crudo

Add `taffy_test_helpers` crate (#755) 2a3e8476b · Nico Burns ·

1#[test]
2#[allow(non_snake_case)]
3fn measure_root__border_box() {
4    #[allow(unused_imports)]
5    use taffy::{prelude::*, Layout};
6    let mut taffy = crate::new_test_tree();
7    let node = taffy
8        .new_leaf_with_context(
9            taffy::style::Style { ..Default::default() },
10            crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal),
11        )
12        .unwrap();
13    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
14    println!("\nComputed tree:");
15    taffy.print_tree(node);
16    println!();
17    let layout = taffy.layout(node).unwrap();
18    let Layout { size, location, .. } = layout;
19    assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
20    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
21    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
22    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
23}
24
25#[test]
26#[allow(non_snake_case)]
27fn measure_root__content_box() {
28    #[allow(unused_imports)]
29    use taffy::{prelude::*, Layout};
30    let mut taffy = crate::new_test_tree();
31    let node = taffy
32        .new_leaf_with_context(
33            taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
34            crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal),
35        )
36        .unwrap();
37    taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
38    println!("\nComputed tree:");
39    taffy.print_tree(node);
40    println!();
41    let layout = taffy.layout(node).unwrap();
42    let Layout { size, location, .. } = layout;
43    assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
44    assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
45    assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
46    assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
47}