⎇ direction-floats
tests/generated/blockgrid/blockgrid_block_in_grid_fixed_larger.rs
Ñawpa willay
Pi imata llamkarqan
ch'uya
Add `taffy_test_helpers` crate (#755)
1#[test]
2#[allow(non_snake_case)]
3fn blockgrid_block_in_grid_fixed_larger__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node0 = taffy
8 .new_leaf_with_context(
9 taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() },
10 crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal),
11 )
12 .unwrap();
13 let node1 =
14 taffy.new_leaf(taffy::style::Style { display: taffy::style::Display::Block, ..Default::default() }).unwrap();
15 let node = taffy
16 .new_with_children(
17 taffy::style::Style {
18 display: taffy::style::Display::Grid,
19 grid_template_columns: vec![length(50f32)],
20 ..Default::default()
21 },
22 &[node0, node1],
23 )
24 .unwrap();
25 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
26 println!("\nComputed tree:");
27 taffy.print_tree(node);
28 println!();
29 let layout = taffy.layout(node).unwrap();
30 let Layout { size, location, .. } = layout;
31 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
32 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
33 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
34 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
35 let layout = taffy.layout(node0).unwrap();
36 let Layout { size, location, .. } = layout;
37 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
38 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
39 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
40 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
41 let layout = taffy.layout(node1).unwrap();
42 let Layout { size, location, .. } = layout;
43 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
44 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
45 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
46 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
47}
48
49#[test]
50#[allow(non_snake_case)]
51fn blockgrid_block_in_grid_fixed_larger__content_box() {
52 #[allow(unused_imports)]
53 use taffy::{prelude::*, Layout};
54 let mut taffy = crate::new_test_tree();
55 let node0 = taffy
56 .new_leaf_with_context(
57 taffy::style::Style {
58 display: taffy::style::Display::Block,
59 box_sizing: taffy::style::BoxSizing::ContentBox,
60 ..Default::default()
61 },
62 crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal),
63 )
64 .unwrap();
65 let node1 = taffy
66 .new_leaf(taffy::style::Style {
67 display: taffy::style::Display::Block,
68 box_sizing: taffy::style::BoxSizing::ContentBox,
69 ..Default::default()
70 })
71 .unwrap();
72 let node = taffy
73 .new_with_children(
74 taffy::style::Style {
75 display: taffy::style::Display::Grid,
76 box_sizing: taffy::style::BoxSizing::ContentBox,
77 grid_template_columns: vec![length(50f32)],
78 ..Default::default()
79 },
80 &[node0, node1],
81 )
82 .unwrap();
83 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
84 println!("\nComputed tree:");
85 taffy.print_tree(node);
86 println!();
87 let layout = taffy.layout(node).unwrap();
88 let Layout { size, location, .. } = layout;
89 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
90 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
91 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
92 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
93 let layout = taffy.layout(node0).unwrap();
94 let Layout { size, location, .. } = layout;
95 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node0, 50f32, size.width);
96 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node0, 10f32, size.height);
97 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
98 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
99 let layout = taffy.layout(node1).unwrap();
100 let Layout { size, location, .. } = layout;
101 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node1, 50f32, size.width);
102 assert_eq!(size.height, 0f32, "height of node {:?}. Expected {}. Actual {}", node1, 0f32, size.height);
103 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node1, 0f32, location.x);
104 assert_eq!(location.y, 10f32, "y of node {:?}. Expected {}. Actual {}", node1, 10f32, location.y);
105}