⎇ 0.5.x
tests/generated/flex/align_content_end_single_line_negative_space.rs
Historia
Quién tocó qué
crudo
Rename Taffy struct to TaffyTree (#580)
1#[test]
2fn align_content_end_single_line_negative_space() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, TaffyTree};
5 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
6 let node00 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_shrink: 0f32,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Percent(0.8f32),
11 height: taffy::style::Dimension::Length(60f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 display: taffy::style::Display::Flex,
20 align_content: Some(taffy::style::AlignContent::End),
21 justify_content: Some(taffy::style::JustifyContent::Center),
22 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Length(10f32) },
23 ..Default::default()
24 },
25 &[node00],
26 )
27 .unwrap();
28 let node = taffy
29 .new_with_children(
30 taffy::style::Style {
31 display: taffy::style::Display::Flex,
32 flex_direction: taffy::style::FlexDirection::Column,
33 size: taffy::geometry::Size {
34 width: taffy::style::Dimension::Length(320f32),
35 height: taffy::style::Dimension::Length(320f32),
36 },
37 border: taffy::geometry::Rect {
38 left: taffy::style::LengthPercentage::Length(60f32),
39 right: taffy::style::LengthPercentage::Length(60f32),
40 top: taffy::style::LengthPercentage::Length(60f32),
41 bottom: taffy::style::LengthPercentage::Length(60f32),
42 },
43 ..Default::default()
44 },
45 &[node0],
46 )
47 .unwrap();
48 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
49 println!("\nComputed tree:");
50 taffy.print_tree(node);
51 println!();
52 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
53 let layout @ Layout { size, location, .. } = taffy.layout(node).unwrap();
54 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
55 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
58 #[cfg(feature = "content_size")]
59 assert_eq!(
60 layout.scroll_width(),
61 0f32,
62 "scroll_width of node {:?}. Expected {}. Actual {}",
63 node,
64 0f32,
65 layout.scroll_width()
66 );
67 #[cfg(feature = "content_size")]
68 assert_eq!(
69 layout.scroll_height(),
70 0f32,
71 "scroll_height of node {:?}. Expected {}. Actual {}",
72 node,
73 0f32,
74 layout.scroll_height()
75 );
76 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
77 let layout @ Layout { size, location, .. } = taffy.layout(node0).unwrap();
78 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
79 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
80 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
81 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
82 #[cfg(feature = "content_size")]
83 assert_eq!(
84 layout.scroll_width(),
85 0f32,
86 "scroll_width of node {:?}. Expected {}. Actual {}",
87 node0,
88 0f32,
89 layout.scroll_width()
90 );
91 #[cfg(feature = "content_size")]
92 assert_eq!(
93 layout.scroll_height(),
94 50f32,
95 "scroll_height of node {:?}. Expected {}. Actual {}",
96 node0,
97 50f32,
98 layout.scroll_height()
99 );
100 #[cfg_attr(not(feature = "content_size"), allow(unused_variables))]
101 let layout @ Layout { size, location, .. } = taffy.layout(node00).unwrap();
102 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
103 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height);
104 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
105 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
106 #[cfg(feature = "content_size")]
107 assert_eq!(
108 layout.scroll_width(),
109 0f32,
110 "scroll_width of node {:?}. Expected {}. Actual {}",
111 node00,
112 0f32,
113 layout.scroll_width()
114 );
115 #[cfg(feature = "content_size")]
116 assert_eq!(
117 layout.scroll_height(),
118 0f32,
119 "scroll_height of node {:?}. Expected {}. Actual {}",
120 node00,
121 0f32,
122 layout.scroll_height()
123 );
124}