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