⎇ 368b7da13d700e20ed1ef0fa2399fade0ca5ea3f
tests/generated/flex/overflow_main_axis_shrink_visible.rs
Historia
Quién tocó qué
crudo
Use tagged pointer to represent size/length values (#769)
1#[test]
2#[allow(non_snake_case)]
3fn overflow_main_axis_shrink_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 { flex_shrink: 1f32, ..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 size: taffy::geometry::Size {
17 width: taffy::style::Dimension::from_length(50f32),
18 height: taffy::style::Dimension::from_length(50f32),
19 },
20 ..Default::default()
21 },
22 &[node0],
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, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, 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, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
38 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, 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}
42
43#[test]
44#[allow(non_snake_case)]
45fn overflow_main_axis_shrink_visible__content_box() {
46 #[allow(unused_imports)]
47 use taffy::{prelude::*, Layout};
48 let mut taffy = crate::new_test_tree();
49 let node0 = taffy
50 .new_leaf_with_context(
51 taffy::style::Style {
52 box_sizing: taffy::style::BoxSizing::ContentBox,
53 flex_shrink: 1f32,
54 ..Default::default()
55 },
56 crate::TestNodeContext::ahem_text("HHHHHHHHHH", crate::WritingMode::Horizontal),
57 )
58 .unwrap();
59 let node = taffy
60 .new_with_children(
61 taffy::style::Style {
62 box_sizing: taffy::style::BoxSizing::ContentBox,
63 size: taffy::geometry::Size {
64 width: taffy::style::Dimension::from_length(50f32),
65 height: taffy::style::Dimension::from_length(50f32),
66 },
67 ..Default::default()
68 },
69 &[node0],
70 )
71 .unwrap();
72 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
73 println!("\nComputed tree:");
74 taffy.print_tree(node);
75 println!();
76 let layout = taffy.layout(node).unwrap();
77 let Layout { size, location, .. } = layout;
78 assert_eq!(size.width, 50f32, "width of node {:?}. Expected {}. Actual {}", node, 50f32, size.width);
79 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node, 50f32, size.height);
80 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
81 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
82 let layout = taffy.layout(node0).unwrap();
83 let Layout { size, location, .. } = layout;
84 assert_eq!(size.width, 100f32, "width of node {:?}. Expected {}. Actual {}", node0, 100f32, size.width);
85 assert_eq!(size.height, 50f32, "height of node {:?}. Expected {}. Actual {}", node0, 50f32, size.height);
86 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node0, 0f32, location.x);
87 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node0, 0f32, location.y);
88}