⎇ 477ff4aff498cbae4cdfbf0cda1ee5b04c784f08
tests/generated/flex/margin_left.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn margin_left() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(10f32), height: auto() },
9 margin: taffy::geometry::Rect {
10 left: taffy::style::LengthPercentageAuto::Length(10f32),
11 right: zero(),
12 top: zero(),
13 bottom: zero(),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 size: taffy::geometry::Size {
22 width: taffy::style::Dimension::Length(100f32),
23 height: taffy::style::Dimension::Length(100f32),
24 },
25 ..Default::default()
26 },
27 &[node0],
28 )
29 .unwrap();
30 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
31 println!("\nComputed tree:");
32 taffy.print_tree(node);
33 println!();
34 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
35 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
36 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
37 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
38 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
39 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
40 #[cfg(feature = "content_size")]
41 assert_eq!(
42 layout.scroll_width(),
43 0f32,
44 "scroll_width of node {:?}. Expected {}. Actual {}",
45 node,
46 0f32,
47 layout.scroll_width()
48 );
49 #[cfg(feature = "content_size")]
50 assert_eq!(
51 layout.scroll_height(),
52 0f32,
53 "scroll_height of node {:?}. Expected {}. Actual {}",
54 node,
55 0f32,
56 layout.scroll_height()
57 );
58 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
59 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
60 assert_eq!(size.width, 10f32, "width of node {:?}. Expected {}. Actual {}", node0, 10f32, size.width);
61 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
62 assert_eq!(location.x, 10f32, "x of node {:?}. Expected {}. Actual {}", node0, 10f32, location.x);
63 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
64 #[cfg(feature = "content_size")]
65 assert_eq!(
66 layout.scroll_width(),
67 0f32,
68 "scroll_width of node {:?}. Expected {}. Actual {}",
69 node0,
70 0f32,
71 layout.scroll_width()
72 );
73 #[cfg(feature = "content_size")]
74 assert_eq!(
75 layout.scroll_height(),
76 0f32,
77 "scroll_height of node {:?}. Expected {}. Actual {}",
78 node0,
79 0f32,
80 layout.scroll_height()
81 );
82}