⎇ float-layout
tests/generated/grid/grid_overflow_inline_axis_visible.rs
History
Who touched what
raw
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn grid_overflow_inline_axis_visible__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 { ..Default::default() },
10 crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal),
11 )
12 .unwrap();
13 let node = taffy
14 .new_with_children(
15 taffy::style::Style {
16 display: taffy::style::Display::Grid,
17 size: taffy::geometry::Size {
18 width: taffy::style::Dimension::from_length(50f32),
19 height: taffy::style::Dimension::from_length(50f32),
20 },
21 ..Default::default()
22 },
23 &[node0],
24 )
25 .unwrap();
26 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
27 println!("\nComputed tree:");
28 taffy.print_tree(node);
29 println!();
30 let layout = taffy.layout(node).unwrap();
31 let Layout { size, location, .. } = layout;
32 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
33 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
34 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
35 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
36 let layout = taffy.layout(node0).unwrap();
37 let Layout { size, location, .. } = layout;
38 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
39 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
40 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
41 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
42}
43
44#[test]
45#[allow(non_snake_case)]
46fn grid_overflow_inline_axis_visible__content_box() {
47 #[allow(unused_imports)]
48 use taffy::{prelude::*, Layout};
49 let mut taffy = crate::new_test_tree();
50 let node0 = taffy
51 .new_leaf_with_context(
52 taffy::style::Style { box_sizing: taffy::style::BoxSizing::ContentBox, ..Default::default() },
53 crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal),
54 )
55 .unwrap();
56 let node = taffy
57 .new_with_children(
58 taffy::style::Style {
59 display: taffy::style::Display::Grid,
60 box_sizing: taffy::style::BoxSizing::ContentBox,
61 size: taffy::geometry::Size {
62 width: taffy::style::Dimension::from_length(50f32),
63 height: taffy::style::Dimension::from_length(50f32),
64 },
65 ..Default::default()
66 },
67 &[node0],
68 )
69 .unwrap();
70 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
71 println!("\nComputed tree:");
72 taffy.print_tree(node);
73 println!();
74 let layout = taffy.layout(node).unwrap();
75 let Layout { size, location, .. } = layout;
76 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
77 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
78 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
79 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
80 let layout = taffy.layout(node0).unwrap();
81 let Layout { size, location, .. } = layout;
82 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
83 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
84 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
85 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
86}