⎇ f99b57fbad456aa2756b374ff40c876e4b9574c2
tests/generated/grid/grid_display_none_fixed_size.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_display_none_fixed_size__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy.new_leaf(taffy::style::Style { flex_grow: 1f32, ..Default::default() }).unwrap();
8 let node1 = taffy
9 .new_leaf(taffy::style::Style {
10 display: taffy::style::Display::None,
11 size: taffy::geometry::Size {
12 width: taffy::style::Dimension::from_length(20f32),
13 height: taffy::style::Dimension::from_length(20f32),
14 },
15 ..Default::default()
16 })
17 .unwrap();
18 let node = taffy
19 .new_with_children(
20 taffy::style::Style {
21 display: taffy::style::Display::Grid,
22 size: taffy::geometry::Size {
23 width: taffy::style::Dimension::from_length(100f32),
24 height: taffy::style::Dimension::from_length(100f32),
25 },
26 ..Default::default()
27 },
28 &[node0, node1],
29 )
30 .unwrap();
31 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
32 println!("\nComputed tree:");
33 taffy.print_tree(node);
34 println!();
35 let layout = taffy.layout(node).unwrap();
36 let Layout { size, location, .. } = layout;
37 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
38 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
41 let layout = taffy.layout(node0).unwrap();
42 let Layout { size, location, .. } = layout;
43 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
44 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
46 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
47 let layout = taffy.layout(node1).unwrap();
48 let Layout { size, location, .. } = layout;
49 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
50 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
51 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
52 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
53}
54
55#[test]
56#[allow(non_snake_case)]
57fn grid_display_none_fixed_size__content_box() {
58 #[allow(unused_imports)]
59 use taffy::{prelude::*, Layout};
60 let mut taffy = crate::new_test_tree();
61 let node0 = taffy
62 .new_leaf(taffy::style::Style {
63 box_sizing: taffy::style::BoxSizing::ContentBox,
64 flex_grow: 1f32,
65 ..Default::default()
66 })
67 .unwrap();
68 let node1 = taffy
69 .new_leaf(taffy::style::Style {
70 display: taffy::style::Display::None,
71 box_sizing: taffy::style::BoxSizing::ContentBox,
72 size: taffy::geometry::Size {
73 width: taffy::style::Dimension::from_length(20f32),
74 height: taffy::style::Dimension::from_length(20f32),
75 },
76 ..Default::default()
77 })
78 .unwrap();
79 let node = taffy
80 .new_with_children(
81 taffy::style::Style {
82 display: taffy::style::Display::Grid,
83 box_sizing: taffy::style::BoxSizing::ContentBox,
84 size: taffy::geometry::Size {
85 width: taffy::style::Dimension::from_length(100f32),
86 height: taffy::style::Dimension::from_length(100f32),
87 },
88 ..Default::default()
89 },
90 &[node0, node1],
91 )
92 .unwrap();
93 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
94 println!("\nComputed tree:");
95 taffy.print_tree(node);
96 println!();
97 let layout = taffy.layout(node).unwrap();
98 let Layout { size, location, .. } = layout;
99 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
100 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
101 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
102 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
103 let layout = taffy.layout(node0).unwrap();
104 let Layout { size, location, .. } = layout;
105 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
106 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node0, 100f32, size.height);
107 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
108 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
109 let layout = taffy.layout(node1).unwrap();
110 let Layout { size, location, .. } = layout;
111 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
112 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
113 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
114 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
115}