⎇ ae87fd0283feff32a5ceffe4c77394ff6ca88d39
tests/generated/grid_minmax_column_with_auto_fixed.rs
Historia
Quién tocó qué
crudo
Grid: Fixes for minmax, fr proportions and distributing space across multiple tracks (#349)
1#[test]
2fn grid_minmax_column_with_auto_fixed() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
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![points(40f32)],
14 grid_template_columns: vec![minmax(points(20f32), points(40f32)), auto()],
15 size: taffy::geometry::Size { width: taffy::style::Dimension::Points(60f32), height: auto() },
16 ..Default::default()
17 },
18 &[node0, node1],
19 )
20 .unwrap();
21 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
22 println!("\nComputed tree:");
23 taffy::debug::print_tree(&taffy, node);
24 println!();
25 let Layout { size, location, .. } = taffy.layout(node).unwrap();
26 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 60f32, size.width);
27 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 40f32, size.height);
28 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
29 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
30 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
31 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.width);
32 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 40f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
35 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
36 assert_eq!(size.width, 20f32, "width of node {:?}. Expected {}. Actual {}", node1.data(), 20f32, size.width);
37 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, size.height);
38 assert_eq!(location.x, 40f32, "x of node {:?}. Expected {}. Actual {}", node1.data(), 40f32, location.x);
39 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1.data(), 0f32, location.y);
40}