⎇ 0.3.x
tests/generated/justify_content_column_start_negative_space.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
1#[test]
2fn justify_content_column_start_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(20f32),
13 },
14 ..Default::default()
15 })
16 .unwrap();
17 let node01 = taffy
18 .new_leaf(taffy::style::Style {
19 flex_shrink: 0f32,
20 size: taffy::geometry::Size {
21 width: taffy::style::Dimension::Percent(0.8f32),
22 height: taffy::style::Dimension::Points(20f32),
23 },
24 ..Default::default()
25 })
26 .unwrap();
27 let node02 = taffy
28 .new_leaf(taffy::style::Style {
29 flex_shrink: 0f32,
30 size: taffy::geometry::Size {
31 width: taffy::style::Dimension::Percent(0.8f32),
32 height: taffy::style::Dimension::Points(20f32),
33 },
34 ..Default::default()
35 })
36 .unwrap();
37 let node0 = taffy
38 .new_with_children(
39 taffy::style::Style {
40 display: taffy::style::Display::Flex,
41 flex_direction: taffy::style::FlexDirection::Column,
42 align_items: Some(taffy::style::AlignItems::Center),
43 justify_content: Some(taffy::style::JustifyContent::Start),
44 size: taffy::geometry::Size { width: auto(), height: taffy::style::Dimension::Points(10f32) },
45 ..Default::default()
46 },
47 &[node00, node01, node02],
48 )
49 .unwrap();
50 let node = taffy
51 .new_with_children(
52 taffy::style::Style {
53 display: taffy::style::Display::Flex,
54 flex_direction: taffy::style::FlexDirection::Column,
55 size: taffy::geometry::Size {
56 width: taffy::style::Dimension::Points(320f32),
57 height: taffy::style::Dimension::Points(320f32),
58 },
59 border: taffy::geometry::Rect {
60 left: taffy::style::LengthPercentage::Points(60f32),
61 right: taffy::style::LengthPercentage::Points(60f32),
62 top: taffy::style::LengthPercentage::Points(60f32),
63 bottom: taffy::style::LengthPercentage::Points(60f32),
64 },
65 ..Default::default()
66 },
67 &[node0],
68 )
69 .unwrap();
70 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
71 println!("\nComputed tree:");
72 taffy::debug::print_tree(&taffy, node);
73 println!();
74 let Layout { size, location, .. } = taffy.layout(node).unwrap();
75 assert_eq!(size.width, 320f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.width);
76 assert_eq!(size.height, 320f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 320f32, size.height);
77 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
78 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
79 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
80 assert_eq!(size.width, 200f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 200f32, size.width);
81 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
82 assert_eq!(location.x, 60f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.x);
83 assert_eq!(location.y, 60f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 60f32, location.y);
84 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
85 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 160f32, size.width);
86 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, size.height);
87 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 20f32, location.x);
88 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
89 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
90 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 160f32, size.width);
91 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 20f32, size.height);
92 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 20f32, location.x);
93 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 20f32, location.y);
94 let Layout { size, location, .. } = taffy.layout(node02).unwrap();
95 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node02.data(), 160f32, size.width);
96 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node02.data(), 20f32, size.height);
97 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node02.data(), 20f32, location.x);
98 assert_eq!(location.y, 40f32, "y of node {:?}. Expected {}. Actual {}", node02.data(), 40f32, location.y);
99}