⎇ 568f643327ec6b4879df0087def7f4e66b6acafb
tests/generated/grid_fit_content_percent_indefinite_argument.rs
Historia
Quién tocó qué
crudo
Rename `Points`/`points` to `Length`/`length` in many APIs (#459)
1#[test]
2fn grid_fit_content_percent_indefinite_argument() {
3 #[allow(unused_imports)]
4 use taffy::{prelude::*, tree::Layout};
5 let mut taffy = taffy::Taffy::new();
6 let node0 = taffy
7 .new_leaf_with_measure(
8 taffy::style::Style { ..Default::default() },
9 taffy::tree::MeasureFunc::Raw(|known_dimensions, available_space| {
10 const TEXT: &str = "HH\u{200b}HH\u{200b}HH";
11 super::measure_standard_text(
12 known_dimensions,
13 available_space,
14 TEXT,
15 super::WritingMode::Horizontal,
16 None,
17 )
18 }),
19 )
20 .unwrap();
21 let node = taffy
22 .new_with_children(
23 taffy::style::Style {
24 display: taffy::style::Display::Grid,
25 grid_template_rows: vec![length(40f32)],
26 grid_template_columns: vec![fit_content(percent(0.5f32))],
27 ..Default::default()
28 },
29 &[node0],
30 )
31 .unwrap();
32 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
33 println!("\nComputed tree:");
34 taffy::util::print_tree(&taffy, node);
35 println!();
36 let Layout { size, location, .. } = taffy.layout(node).unwrap();
37 assert_eq!(size.width, 60f32, "width of node {:?}. Expected {}. Actual {}", node, 60f32, size.width);
38 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node, 40f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
41 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
42 assert_eq!(size.width, 30f32, "width of node {:?}. Expected {}. Actual {}", node0, 30f32, size.width);
43 assert_eq!(size.height, 40f32, "height of node {:?}. Expected {}. Actual {}", node0, 40f32, size.height);
44 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
45 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
46}