⎇ dab541d6104d58e2e10ce90c4a1dad0b703160cd
tests/generated/bevy_issue_9530.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn bevy_issue_9530() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf(taffy::style::Style {
8 flex_direction: taffy::style::FlexDirection::Column,
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Percent(1f32),
11 height: taffy::style::Dimension::Length(20f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node10 = taffy
17 .new_leaf(taffy::style::Style {
18 size: taffy::geometry::Size {
19 width: taffy::style::Dimension::Percent(1f32),
20 height: taffy::style::Dimension::Length(50f32),
21 },
22 ..Default::default()
23 })
24 .unwrap();
25 let node11 = taffy . new_leaf_with_measure (taffy :: style :: Style { align_items : Some (taffy :: style :: AlignItems :: Center) , align_content : Some (taffy :: style :: AlignContent :: Center) , justify_content : Some (taffy :: style :: JustifyContent :: Center) , flex_grow : 1f32 , margin : taffy :: geometry :: Rect { left : taffy :: style :: LengthPercentageAuto :: Length (20f32) , right : taffy :: style :: LengthPercentageAuto :: Length (20f32) , top : taffy :: style :: LengthPercentageAuto :: Length (20f32) , bottom : taffy :: style :: LengthPercentageAuto :: Length (20f32) , } , .. Default :: default () } , taffy :: tree :: MeasureFunc :: Raw (| known_dimensions , available_space | { const TEXT : & str = "HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH\u{200b}HHHH" ; super :: measure_standard_text (known_dimensions , available_space , TEXT , super :: WritingMode :: Horizontal , None) }) ,) . unwrap () ;
26 let node12 = taffy
27 .new_leaf(taffy::style::Style {
28 size: taffy::geometry::Size {
29 width: taffy::style::Dimension::Percent(1f32),
30 height: taffy::style::Dimension::Length(50f32),
31 },
32 ..Default::default()
33 })
34 .unwrap();
35 let node1 = taffy
36 .new_with_children(
37 taffy::style::Style {
38 flex_direction: taffy::style::FlexDirection::Column,
39 flex_grow: 1f32,
40 size: taffy::geometry::Size { width: taffy::style::Dimension::Percent(1f32), height: auto() },
41 margin: taffy::geometry::Rect {
42 left: taffy::style::LengthPercentageAuto::Length(20f32),
43 right: taffy::style::LengthPercentageAuto::Length(20f32),
44 top: taffy::style::LengthPercentageAuto::Length(20f32),
45 bottom: taffy::style::LengthPercentageAuto::Length(20f32),
46 },
47 padding: taffy::geometry::Rect {
48 left: taffy::style::LengthPercentage::Length(20f32),
49 right: taffy::style::LengthPercentage::Length(20f32),
50 top: taffy::style::LengthPercentage::Length(20f32),
51 bottom: taffy::style::LengthPercentage::Length(20f32),
52 },
53 ..Default::default()
54 },
55 &[node10, node11, node12],
56 )
57 .unwrap();
58 let node = taffy
59 .new_with_children(
60 taffy::style::Style {
61 flex_direction: taffy::style::FlexDirection::Column,
62 align_items: Some(taffy::style::AlignItems::Center),
63 align_content: Some(taffy::style::AlignContent::Center),
64 size: taffy::geometry::Size {
65 width: taffy::style::Dimension::Length(300f32),
66 height: taffy::style::Dimension::Length(300f32),
67 },
68 margin: taffy::geometry::Rect {
69 left: taffy::style::LengthPercentageAuto::Auto,
70 right: taffy::style::LengthPercentageAuto::Auto,
71 top: taffy::style::LengthPercentageAuto::Auto,
72 bottom: taffy::style::LengthPercentageAuto::Auto,
73 },
74 ..Default::default()
75 },
76 &[node0, node1],
77 )
78 .unwrap();
79 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
80 println!("\nComputed tree:");
81 taffy::util::print_tree(&taffy, node);
82 println!();
83 let Layout { size, location, .. } = taffy.layout(node).unwrap();
84 assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node, 300f32, size.width);
85 assert_eq!(size.height, 300f32, "height of node {:?}. Expected {}. Actual {}", node, 300f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
88 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
89 assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node0, 300f32, size.width);
90 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
93 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
94 assert_eq!(size.width, 300f32, "width of node {:?}. Expected {}. Actual {}", node1, 300f32, size.width);
95 assert_eq!(size.height, 420f32, "height of node {:?}. Expected {}. Actual {}", node1, 420f32, size.height);
96 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
97 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node1, 20f32, location.y);
98 let Layout { size, location, .. } = taffy.layout(node10).unwrap();
99 assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node10, 260f32, size.width);
100 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node10, 50f32, size.height);
101 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node10, 20f32, location.x);
102 assert_eq!(location.y, 20f32, "y of node {:?}. Expected {}. Actual {}", node10, 20f32, location.y);
103 let Layout { size, location, .. } = taffy.layout(node11).unwrap();
104 assert_eq!(size.width, 220f32, "width of node {:?}. Expected {}. Actual {}", node11, 220f32, size.width);
105 assert_eq!(size.height, 240f32, "height of node {:?}. Expected {}. Actual {}", node11, 240f32, size.height);
106 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node11, 40f32, location.x);
107 assert_eq!(location.y, 90f32, "y of node {:?}. Expected {}. Actual {}", node11, 90f32, location.y);
108 let Layout { size, location, .. } = taffy.layout(node12).unwrap();
109 assert_eq!(size.width, 260f32, "width of node {:?}. Expected {}. Actual {}", node12, 260f32, size.width);
110 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node12, 50f32, size.height);
111 assert_eq!(location.x, 20f32, "x of node {:?}. Expected {}. Actual {}", node12, 20f32, location.x);
112 assert_eq!(location.y, 350f32, "y of node {:?}. Expected {}. Actual {}", node12, 350f32, location.y);
113}