⎇ 9f1d71c97e0852760580b7d7bb30f503baa6a988
tests/generated/leaf/leaf_with_content_and_padding.rs
History
Who touched what
raw
Generated tests: only assert scroll width/height for nodes that are scroll containers (#726)
1#[test]
2#[allow(non_snake_case)]
3fn leaf_with_content_and_padding__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node = taffy
8 .new_leaf_with_context(
9 taffy::style::Style {
10 padding: taffy::geometry::Rect {
11 left: taffy::style::LengthPercentage::Length(8f32),
12 right: taffy::style::LengthPercentage::Length(4f32),
13 top: taffy::style::LengthPercentage::Length(2f32),
14 bottom: taffy::style::LengthPercentage::Length(6f32),
15 },
16 ..Default::default()
17 },
18 crate::TextMeasure {
19 text_content: "HHHH",
20 writing_mode: crate::WritingMode::Horizontal,
21 _aspect_ratio: None,
22 },
23 )
24 .unwrap();
25 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
26 println!("\nComputed tree:");
27 taffy.print_tree(node);
28 println!();
29 let layout = taffy.layout(node).unwrap();
30 let Layout { size, location, .. } = layout;
31 assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width);
32 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
35}
36
37#[test]
38#[allow(non_snake_case)]
39fn leaf_with_content_and_padding__content_box() {
40 #[allow(unused_imports)]
41 use taffy::{prelude::*, tree::Layout, TaffyTree};
42 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
43 let node = taffy
44 .new_leaf_with_context(
45 taffy::style::Style {
46 box_sizing: taffy::style::BoxSizing::ContentBox,
47 padding: taffy::geometry::Rect {
48 left: taffy::style::LengthPercentage::Length(8f32),
49 right: taffy::style::LengthPercentage::Length(4f32),
50 top: taffy::style::LengthPercentage::Length(2f32),
51 bottom: taffy::style::LengthPercentage::Length(6f32),
52 },
53 ..Default::default()
54 },
55 crate::TextMeasure {
56 text_content: "HHHH",
57 writing_mode: crate::WritingMode::Horizontal,
58 _aspect_ratio: None,
59 },
60 )
61 .unwrap();
62 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
63 println!("\nComputed tree:");
64 taffy.print_tree(node);
65 println!();
66 let layout = taffy.layout(node).unwrap();
67 let Layout { size, location, .. } = layout;
68 assert_eq!(size.width, 52f32, "width of node {:?}. Expected {}. Actual {}", node, 52f32, size.width);
69 assert_eq!(size.height, 18f32, "height of node {:?}. Expected {}. Actual {}", node, 18f32, size.height);
70 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
72}