⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/measure_root.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Add `taffy_test_helpers` crate (#755)
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}