⎇ e6255f79aa9a3f8065504fddb315ff4a6dfe6d0f
tests/generated/flex/padding_no_child.rs
Historia
Quién tocó qué
crudo
Implement `box-sizing: content-box` (#675)
1#[test]
2#[allow(non_snake_case)]
3fn padding_no_child__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(taffy::style::Style {
9 padding: taffy::geometry::Rect {
10 left: taffy::style::LengthPercentage::Length(10f32),
11 right: taffy::style::LengthPercentage::Length(10f32),
12 top: taffy::style::LengthPercentage::Length(10f32),
13 bottom: taffy::style::LengthPercentage::Length(10f32),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
19 println!("\nComputed tree:");
20 taffy.print_tree(node);
21 println!();
22 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
23 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
24 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
25 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
26 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
27 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
28 #[cfg(feature = "content_size")]
29 assert_eq!(
30 layout.scroll_width(),
31 0f32,
32 "scroll_width of node {:?}. Expected {}. Actual {}",
33 node,
34 0f32,
35 layout.scroll_width()
36 );
37 #[cfg(feature = "content_size")]
38 assert_eq!(
39 layout.scroll_height(),
40 0f32,
41 "scroll_height of node {:?}. Expected {}. Actual {}",
42 node,
43 0f32,
44 layout.scroll_height()
45 );
46}
47
48#[test]
49#[allow(non_snake_case)]
50fn padding_no_child__content_box() {
51 #[allow(unused_imports)]
52 use taffy::{prelude::*, tree::Layout, TaffyTree};
53 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
54 let node = taffy
55 .new_leaf(taffy::style::Style {
56 box_sizing: taffy::style::BoxSizing::ContentBox,
57 padding: taffy::geometry::Rect {
58 left: taffy::style::LengthPercentage::Length(10f32),
59 right: taffy::style::LengthPercentage::Length(10f32),
60 top: taffy::style::LengthPercentage::Length(10f32),
61 bottom: taffy::style::LengthPercentage::Length(10f32),
62 },
63 ..Default::default()
64 })
65 .unwrap();
66 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
67 println!("\nComputed tree:");
68 taffy.print_tree(node);
69 println!();
70 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
71 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
72 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node, 20f32, size.width);
73 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
76 #[cfg(feature = "content_size")]
77 assert_eq!(
78 layout.scroll_width(),
79 0f32,
80 "scroll_width of node {:?}. Expected {}. Actual {}",
81 node,
82 0f32,
83 layout.scroll_width()
84 );
85 #[cfg(feature = "content_size")]
86 assert_eq!(
87 layout.scroll_height(),
88 0f32,
89 "scroll_height of node {:?}. Expected {}. Actual {}",
90 node,
91 0f32,
92 layout.scroll_height()
93 );
94}