⎇ 48e4800f14c6af5cd26275fb570d11b93e279654
tests/generated/flex/align_content_center_single_line_negative_space.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
1#[test]
2fn align_content_center_single_line_negative_space() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::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::Center),
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(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
49 println!("\nComputed tree:");
50 taffy::util::print_tree(&taffy, node);
51 println!();
52 let Layout { size, location, .. } = taffy.layout(node).unwrap();
53 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node, 320f32, size.width);
54 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node, 320f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
57 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
58 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0, 200f32, size.width);
59 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
60 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0, 60f32, location.x);
61 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0, 60f32, location.y);
62 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
63 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00, 160f32, size.width);
64 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00, 60f32, size.height);
65 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00, 20f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
67}