⎇ float-layout
tests/generated/flex/intrinsic_sizing_cross_size_column.rs
History
Who touched what
raw
Add `taffy_test_helpers` crate (#755)
1#[test]
2#[allow(non_snake_case)]
3fn intrinsic_sizing_cross_size_column__border_box() {
4 #[allow(unused_imports)]
5 use taffy::{prelude::*, Layout};
6 let mut taffy = crate::new_test_tree();
7 let node = taffy
8 .new_leaf_with_context(
9 taffy::style::Style { flex_direction: taffy::style::FlexDirection::Column, ..Default::default() },
10 crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal),
11 )
12 .unwrap();
13 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
14 println!("\nComputed tree:");
15 taffy.print_tree(node);
16 println!();
17 let layout = taffy.layout(node).unwrap();
18 let Layout { size, location, .. } = layout;
19 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
20 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
21 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
22 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
23}
24
25#[test]
26#[allow(non_snake_case)]
27fn intrinsic_sizing_cross_size_column__content_box() {
28 #[allow(unused_imports)]
29 use taffy::{prelude::*, Layout};
30 let mut taffy = crate::new_test_tree();
31 let node = taffy
32 .new_leaf_with_context(
33 taffy::style::Style {
34 box_sizing: taffy::style::BoxSizing::ContentBox,
35 flex_direction: taffy::style::FlexDirection::Column,
36 ..Default::default()
37 },
38 crate::TestNodeContext::ahem_text("HH\u{200b}HH", crate::WritingMode::Horizontal),
39 )
40 .unwrap();
41 taffy.compute_layout_with_measure(node, taffy::geometry::Size::MAX_CONTENT, crate::test_measure_function).unwrap();
42 println!("\nComputed tree:");
43 taffy.print_tree(node);
44 println!();
45 let layout = taffy.layout(node).unwrap();
46 let Layout { size, location, .. } = layout;
47 assert_eq!(size.width, 40f32, "width of node {:?}. Expected {}. Actual {}", node, 40f32, size.width);
48 assert_eq!(size.height, 10f32, "height of node {:?}. Expected {}. Actual {}", node, 10f32, size.height);
49 assert_eq!(location.x, 0f32, "x of node {:?}. Expected {}. Actual {}", node, 0f32, location.x);
50 assert_eq!(location.y, 0f32, "y of node {:?}. Expected {}. Actual {}", node, 0f32, location.y);
51}