diff --git a/tests/flex_wrap_test.rs b/tests/flex_wrap_test.rs index 7345b7f..ea1587d 100644 --- a/tests/flex_wrap_test.rs +++ b/tests/flex_wrap_test.rs @@ -390,4 +390,84 @@ mod tests { assert_eq!(50.0, get_height(&mut root_child1)); } + + #[test] + fn flex_wrap_wrap_to_child_height() { + let mut root = node_create(); + + let mut root_child0 = node_create(); + set_flex_direction(&mut root_child0, FlexDirection::FlexDirectionRow); + set_align_items(&mut root_child0, FlexAlign::FlexAlignStart); + set_flex_wrap(&mut root_child0, FlexWrapNode::FlexWrap); + insert_child(&mut root, &mut root_child0, 0); + + let mut root_child0_child0 = node_create(); + set_width(&mut root_child0_child0, 100.0); + insert_child(&mut root_child0, &mut root_child0_child0, 0); + + let mut root_child0_child0_child0 = node_create(); + set_width(&mut root_child0_child0_child0, 100.0); + set_height(&mut root_child0_child0_child0, 100.0); + insert_child(&mut root_child0_child0, &mut root_child0_child0_child0, 0); + + let mut root_child1 = node_create(); + set_width(&mut root_child1, 100.0); + set_height(&mut root_child1, 100.0); + insert_child(&mut root, &mut root_child1, 1); + + layout!(&mut root); + + assert_eq!(0.0, get_left(&mut root)); + assert_eq!(0.0, get_top(&mut root)); + assert_eq!(100.0, get_width(&mut root)); + assert_eq!(200.0, get_height(&mut root)); + + assert_eq!(0.0, get_left(&mut root_child0)); + assert_eq!(0.0, get_top(&mut root_child0)); + assert_eq!(100.0, get_width(&mut root_child0)); + assert_eq!(100.0, get_height(&mut root_child0)); + + assert_eq!(0.0, get_left(&mut root_child0_child0)); + assert_eq!(0.0, get_top(&mut root_child0_child0)); + assert_eq!(100.0, get_width(&mut root_child0_child0)); + assert_eq!(100.0, get_height(&mut root_child0_child0)); + + assert_eq!(0.0, get_left(&mut root_child0_child0_child0)); + assert_eq!(0.0, get_top(&mut root_child0_child0_child0)); + assert_eq!(100.0, get_width(&mut root_child0_child0_child0)); + assert_eq!(100.0, get_height(&mut root_child0_child0_child0)); + + assert_eq!(0.0, get_left(&mut root_child1)); + assert_eq!(100.0, get_top(&mut root_child1)); + assert_eq!(100.0, get_width(&mut root_child1)); + assert_eq!(100.0, get_height(&mut root_child1)); + + layout!(&mut root, std::f64::NAN, std::f64::NAN, Direction::RTL); + + assert_eq!(0.0, get_left(&mut root)); + assert_eq!(0.0, get_top(&mut root)); + assert_eq!(100.0, get_width(&mut root)); + assert_eq!(200.0, get_height(&mut root)); + + assert_eq!(0.0, get_left(&mut root_child0)); + assert_eq!(0.0, get_top(&mut root_child0)); + assert_eq!(100.0, get_width(&mut root_child0)); + assert_eq!(100.0, get_height(&mut root_child0)); + + assert_eq!(0.0, get_left(&mut root_child0_child0)); + assert_eq!(0.0, get_top(&mut root_child0_child0)); + assert_eq!(100.0, get_width(&mut root_child0_child0)); + assert_eq!(100.0, get_height(&mut root_child0_child0)); + + assert_eq!(0.0, get_left(&mut root_child0_child0_child0)); + assert_eq!(0.0, get_top(&mut root_child0_child0_child0)); + assert_eq!(100.0, get_width(&mut root_child0_child0_child0)); + assert_eq!(100.0, get_height(&mut root_child0_child0_child0)); + + assert_eq!(0.0, get_left(&mut root_child1)); + assert_eq!(100.0, get_top(&mut root_child1)); + assert_eq!(100.0, get_width(&mut root_child1)); + assert_eq!(100.0, get_height(&mut root_child1)); + + } }