⎇ c9c40576df24056c2f0f8b421d8046d33bb1cc2d
tests/generated/grid/grid_percent_tracks_indefinite_only.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Replace per-node measure functions with a single measure function + per-node context (#490)
1#[test]
2fn grid_percent_tracks_indefinite_only() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout, Taffy};
5 let mut taffy: Taffy<crate::TextMeasure> = Taffy::new();
6 let node0 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
7 let node1 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
8 let node2 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
9 let node3 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
10 let node4 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
11 let node5 = taffy.new_leaf(taffy::style::Style { ..Default::default() }).unwrap();
12 let node = taffy
13 .new_with_children(
14 taffy::style::Style {
15 display: taffy::style::Display::Grid,
16 grid_template_rows: vec![percent(0.3f32), percent(0.6f32)],
17 grid_template_columns: vec![percent(0.1f32), percent(0.2f32), percent(0.3f32)],
18 ..Default::default()
19 },
20 &[node0, node1, node2, node3, node4, node5],
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 { size, location, .. } = taffy.layout(node).unwrap();
28 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node, 0f32, size.width);
29 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node, 0f32, 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 { size, location, .. } = taffy.layout(node0).unwrap();
33 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node0, 0f32, size.width);
34 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node0, 0f32, size.height);
35 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
36 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
37 let Layout { size, location, .. } = taffy.layout(node1).unwrap();
38 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node1, 0f32, size.width);
39 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node1, 0f32, location.y);
42 let Layout { size, location, .. } = taffy.layout(node2).unwrap();
43 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node2, 0f32, size.width);
44 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node2, 0f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node2, 0f32, location.x);
46 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node2, 0f32, location.y);
47 let Layout { size, location, .. } = taffy.layout(node3).unwrap();
48 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node3, 0f32, size.width);
49 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node3, 0f32, size.height);
50 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node3, 0f32, location.x);
51 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node3, 0f32, location.y);
52 let Layout { size, location, .. } = taffy.layout(node4).unwrap();
53 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node4, 0f32, size.width);
54 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node4, 0f32, size.height);
55 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node4, 0f32, location.x);
56 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node4, 0f32, location.y);
57 let Layout { size, location, .. } = taffy.layout(node5).unwrap();
58 assert_eq!(size.width, 0f32, "width of node {:?}. Expected {}. Actual {}", node5, 0f32, size.width);
59 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node5, 0f32, size.height);
60 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node5, 0f32, location.x);
61 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node5, 0f32, location.y);
62}