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