⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/flex/measure_child.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Add `taffy_test_helpers` crate (#755)
1#[test]
2#[allow(non_snake_case)]
3fn measure_child__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = 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 let node = taffy.new_with_children(taffy::style::Style { ..Default::default() }, &[node0]).unwrap();
14 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
15 println!("\nComputed tree:");
16 taffy.print_tree(node);
17 println!();
18 let layout = taffy.layout(node).unwrap();
19 let Layout { size, location, .. } = layout;
20 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
21 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
22 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
23 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
24 let layout = taffy.layout(node0).unwrap();
25 let Layout { size, location, .. } = layout;
26 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
27 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
28 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
29 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
30}
31
32#[test]
33#[allow(non_snake_case)]
34fn measure_child__content_box() {
35 #[allow(unused_imports)]
36 use taffy::{prelude::*, Layout};
37 let mut taffy = crate::new_test_tree();
38 let node0 = taffy
39 .new_leaf_with_context(
40 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
41 crate::TestNodeContext::ahem_text("HHHHHH", crate::WritingMode::Horizontal),
42 )
43 .unwrap();
44 let node = taffy
45 .new_with_children(
46 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
47 &[node0],
48 )
49 .unwrap();
50 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
51 println!("\nComputed tree:");
52 taffy.print_tree(node);
53 println!();
54 let layout = taffy.layout(node).unwrap();
55 let Layout { size, location, .. } = layout;
56 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
57 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
58 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
59 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
60 let layout = taffy.layout(node0).unwrap();
61 let Layout { size, location, .. } = layout;
62 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node0, 60f32, size.width);
63 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
64 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
65 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
66}