⎇ 837d03fde9d8a4efa0f4eaf1e8be2fd34a719a50
tests/generated/align_content_start_single_line_negative_space.rs
History
Who touched what
raw
1#[test]
2fn align_content_start_single_line_negative_space() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 flex_shrink: 0f32,
10 size: taffy::geometry::Size {
11 width: taffy::style::Dimension::Percent(0.8f32),
12 height: taffy::style::Dimension::Points(60f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node0 = taffy
18 .new_with_children(
19 taffy::style::Style {
20 display: taffy::style::Display::Flex,
21 align_content: Some(taffy::style::AlignContent::Start),
22 justify_content: Some(taffy::style::JustifyContent::Center),
23 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
24 ..Default::default()
25 },
26 &[node00],
27 )
28 .unwrap();
29 let node = taffy
30 .new_with_children(
31 taffy::style::Style {
32 display: taffy::style::Display::Flex,
33 flex_direction: taffy::style::FlexDirection::Column,
34 size: taffy::geometry::Size {
35 width: taffy::style::Dimension::Points(320f32),
36 height: taffy::style::Dimension::Points(320f32),
37 },
38 border: taffy::geometry::Rect {
39 left: taffy::style::LengthPercentage::Points(60f32),
40 right: taffy::style::LengthPercentage::Points(60f32),
41 top: taffy::style::LengthPercentage::Points(60f32),
42 bottom: taffy::style::LengthPercentage::Points(60f32),
43 },
44 ..Default::default()
45 },
46 &[node0],
47 )
48 .unwrap();
49 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
50 println!("\nComputed tree:");
51 taffy::debug::print_tree(&taffy, node);
52 println!();
53 let Layout { size, location, .. } = taffy.layout(node).unwrap();
54 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
55 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.height);
56 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
57 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
58 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
59 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 200f32, size.width);
60 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
61 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.x);
62 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.y);
63 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
64 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 160f32, size.width);
65 assert_eq!(size.height, 60f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 60f32, size.height);
66 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, location.x);
67 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
68}