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