⎇ 9f1d71c97e0852760580b7d7bb30f503baa6a988
tests/generated/gridflex/gridflex_kitchen_sink_minimise2.rs
Historia
Quién tocó qué
crudo
Generated tests: only assert scroll width/height for nodes that are scroll containers (#726)
1#[test]
2#[allow(non_snake_case)]
3fn gridflex_kitchen_sink_minimise2__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, tree::Layout, TaffyTree};
6 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
7 let node00 = taffy
8 .new_leaf(taffy::style::Style {
9 size: taffy::geometry::Size {
10 width: taffy::style::Dimension::Length(20f32),
11 height: taffy::style::Dimension::Length(20f32),
12 },
13 ..Default::default()
14 })
15 .unwrap();
16 let node0 = taffy
17 .new_with_children(
18 taffy::style::Style {
19 display: taffy::style::Display::Grid,
20 grid_template_rows: vec![auto()],
21 grid_template_columns: vec![auto()],
22 ..Default::default()
23 },
24 &[node00],
25 )
26 .unwrap();
27 let node = taffy
28 .new_with_children(
29 taffy::style::Style {
30 flex_grow: 1f32,
31 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
32 ..Default::default()
33 },
34 &[node0],
35 )
36 .unwrap();
37 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
38 println!("\nComputed tree:");
39 taffy.print_tree(node);
40 println!();
41 let layout = taffy.layout(node).unwrap();
42 let Layout { size, location, .. } = layout;
43 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
44 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
46 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
47 let layout = taffy.layout(node0).unwrap();
48 let Layout { size, location, .. } = layout;
49 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
50 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
52 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
53 let layout = taffy.layout(node00).unwrap();
54 let Layout { size, location, .. } = layout;
55 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width);
56 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
57 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
58 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
59}
60
61#[test]
62#[allow(non_snake_case)]
63fn gridflex_kitchen_sink_minimise2__content_box() {
64 #[allow(unused_imports)]
65 use taffy::{prelude::*, tree::Layout, TaffyTree};
66 let mut taffy: TaffyTree<crate::TextMeasure> = TaffyTree::new();
67 let node00 = taffy
68 .new_leaf(taffy::style::Style {
69 box_sizing: taffy::style::BoxSizing::ContentBox,
70 size: taffy::geometry::Size {
71 width: taffy::style::Dimension::Length(20f32),
72 height: taffy::style::Dimension::Length(20f32),
73 },
74 ..Default::default()
75 })
76 .unwrap();
77 let node0 = taffy
78 .new_with_children(
79 taffy::style::Style {
80 display: taffy::style::Display::Grid,
81 box_sizing: taffy::style::BoxSizing::ContentBox,
82 grid_template_rows: vec![auto()],
83 grid_template_columns: vec![auto()],
84 ..Default::default()
85 },
86 &[node00],
87 )
88 .unwrap();
89 let node = taffy
90 .new_with_children(
91 taffy::style::Style {
92 box_sizing: taffy::style::BoxSizing::ContentBox,
93 flex_grow: 1f32,
94 size: taffy::geometry::Size { width: taffy::style::Dimension::Length(50f32), height: auto() },
95 ..Default::default()
96 },
97 &[node0],
98 )
99 .unwrap();
100 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
101 println!("\nComputed tree:");
102 taffy.print_tree(node);
103 println!();
104 let layout = taffy.layout(node).unwrap();
105 let Layout { size, location, .. } = layout;
106 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
107 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node, 20f32, size.height);
108 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
109 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
110 let layout = taffy.layout(node0).unwrap();
111 let Layout { size, location, .. } = layout;
112 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node0, 20f32, size.width);
113 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node0, 20f32, size.height);
114 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
115 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
116 let layout = taffy.layout(node00).unwrap();
117 let Layout { size, location, .. } = layout;
118 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node00, 20f32, size.width);
119 assert_eq!(size.height, 20f32, "height of node {:?}. Expected {}. Actual {}", node00, 20f32, size.height);
120 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00, 0f32, location.x);
121 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00, 0f32, location.y);
122}