Skip to content

Commit

Permalink
feat(test): passed case of flex_wrap_wrap_to_child_height
Browse files Browse the repository at this point in the history
  • Loading branch information
meloalright committed Nov 13, 2024
1 parent 2aea11f commit f1891c8
Showing 1 changed file with 80 additions and 0 deletions.
80 changes: 80 additions & 0 deletions tests/flex_wrap_test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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));

}
}

0 comments on commit f1891c8

Please sign in to comment.