⎇ 40dd6120fc73aa866f30e52a51d1abaf39adce6f
tests/generated/flex/absolute_layout_no_size.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn absolute_layout_no_size__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf(taffy::style::Style { position: taffy::style::Position::Absolute, ..Default::default() })
9 .unwrap();
10 let node = taffy
11 .new_with_children(
12 taffy::style::Style {
13 size: taffy::geometry::Size {
14 width: taffy::style::Dimension::from_length(100f32),
15 height: taffy::style::Dimension::from_length(100f32),
16 },
17 ..Default::default()
18 },
19 &[node0],
20 )
21 .unwrap();
22 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
23 println!("\nComputed tree:");
24 taffy.print_tree(node);
25 println!();
26 let layout = taffy.layout(node).unwrap();
27 let Layout { size, location, .. } = layout;
28 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
29 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
30 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
31 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
32 let layout = taffy.layout(node0).unwrap();
33 let Layout { size, location, .. } = layout;
34 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
35 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
36 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
37 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
38}
39
40#[test]
41#[allow(non_snake_case)]
42fn absolute_layout_no_size__content_box() {
43 #[allow(unused_imports)]
44 use taffy::{prelude::*, Layout};
45 let mut taffy = crate::new_test_tree();
46 let node0 = taffy
47 .new_leaf(taffy::style::Style {
48 box_sizing: taffy::style::BoxSizing::ContentBox,
49 position: taffy::style::Position::Absolute,
50 ..Default::default()
51 })
52 .unwrap();
53 let node = taffy
54 .new_with_children(
55 taffy::style::Style {
56 box_sizing: taffy::style::BoxSizing::ContentBox,
57 size: taffy::geometry::Size {
58 width: taffy::style::Dimension::from_length(100f32),
59 height: taffy::style::Dimension::from_length(100f32),
60 },
61 ..Default::default()
62 },
63 &[node0],
64 )
65 .unwrap();
66 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
67 println!("\nComputed tree:");
68 taffy.print_tree(node);
69 println!();
70 let layout = taffy.layout(node).unwrap();
71 let Layout { size, location, .. } = layout;
72 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node, 100f32, size.width);
73 assert_eq!(size.height, 100f32, "height of node {:?}. Expected {}. Actual {}", node, 100f32, size.height);
74 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
75 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
76 let layout = taffy.layout(node0).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
79 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
80 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
82}