⎇ ae87fd0283feff32a5ceffe4c77394ff6ca88d39
tests/generated/grid_max_width_greater_than_max_content.rs
Historia
Quién tocó qué
crudo
1#[test]
2fn grid_max_width_greater_than_max_content() {
3 use slotmap::Key;
4 #[allow(unused_imports)]
5 use taffy::{layout::Layout, prelude::*};
6 let mut taffy = taffy::Taffy::new();
7 let node00 = taffy
8 .new_leaf_with_measure(
9 taffy::style::Style { ..Default::default() },
10 taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
11 const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH";
12 super::measure_standard_text(
13 known_dimensions,
14 available_space,
15 TEXT,
16 super::WritingMode::Horizontal,
17 None,
18 )
19 }),
20 )
21 .unwrap();
22 let node01 = taffy
23 .new_leaf_with_measure(
24 taffy::style::Style { ..Default::default() },
25 taffy::node::MeasureFunc::Raw(|known_dimensions, available_space| {
26 const TEXT: &str = "HH\u{200b}HH\u{200b}HH\u{200b}HH";
27 super::measure_standard_text(
28 known_dimensions,
29 available_space,
30 TEXT,
31 super::WritingMode::Horizontal,
32 None,
33 )
34 }),
35 )
36 .unwrap();
37 let node0 = taffy
38 .new_with_children(
39 taffy::style::Style {
40 display: taffy::style::Display::Grid,
41 grid_template_columns: vec![auto(), auto()],
42 max_size: taffy::geometry::Size { width: taffy::style::Dimension::Points(400f32), height: auto() },
43 ..Default::default()
44 },
45 &[node00, node01],
46 )
47 .unwrap();
48 let node = taffy
49 .new_with_children(
50 taffy::style::Style {
51 display: taffy::style::Display::Grid,
52 grid_template_columns: vec![max_content()],
53 ..Default::default()
54 },
55 &[node0],
56 )
57 .unwrap();
58 taffy.compute_layout(node, taffy::geometry::Size::MAX_CONTENT).unwrap();
59 println!("\nComputed tree:");
60 taffy::debug::print_tree(&taffy, node);
61 println!();
62 let Layout { size, location, .. } = taffy.layout(node).unwrap();
63 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node.data(), 160f32, size.width);
64 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node.data(), 10f32, size.height);
65 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.x);
66 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node.data(), 0f32, location.y);
67 let Layout { size, location, .. } = taffy.layout(node0).unwrap();
68 assert_eq!(size.width, 160f32, "width of node {:?}. Expected {}. Actual {}", node0.data(), 160f32, size.width);
69 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0.data(), 10f32, size.height);
70 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.x);
71 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0.data(), 0f32, location.y);
72 let Layout { size, location, .. } = taffy.layout(node00).unwrap();
73 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node00.data(), 80f32, size.width);
74 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node00.data(), 10f32, size.height);
75 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.x);
76 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node00.data(), 0f32, location.y);
77 let Layout { size, location, .. } = taffy.layout(node01).unwrap();
78 assert_eq!(size.width, 80f32, "width of node {:?}. Expected {}. Actual {}", node01.data(), 80f32, size.width);
79 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node01.data(), 10f32, size.height);
80 assert_eq!(location.x, 80f32, "x of node {:?}. Expected {}. Actual {}", node01.data(), 80f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node01.data(), 0f32, location.y);
82}