extern crate ordered_float;
extern crate yoga;
mod test_utils;
use yoga::*;
#[test]
fn test_align_content_flex_start_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_flex_start_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(10_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(10_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(20_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(10_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(10_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(20_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_flex_start_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_flex_start_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_flex_start_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_flex_start_without_height_on_children() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(10_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(10_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(20_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(10_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(10_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(20_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_flex_start_with_flex() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
root_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_flex_grow(1_f32);
root_child3.set_flex_shrink(1_f32);
root_child3.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(40_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(80_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(80_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(40_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(120_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(40_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(80_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(80_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(40_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(120_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_flex_end_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::FlexEnd);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_flex_end_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::FlexEnd);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(90_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(90_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(100_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(100_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(110_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(90_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(90_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(100_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(100_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(110_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_flex_end_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::FlexEnd);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(110_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(110_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(110_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(110_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_flex_end_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::FlexEnd);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-50_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(-10_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-50_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(-10_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_flex_end_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::FlexEnd);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-70_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-40_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(-10_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-70_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-40_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(-10_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_center_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Center);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_center_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Center);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(45_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(45_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(65_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(45_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(45_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(65_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_center_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Center);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_center_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::Center);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-25_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-5_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(15_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-25_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-5_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(15_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_center_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::Center);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-35_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-5_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(25_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(-35_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(-5_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(25_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_between_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceBetween);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_between_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceBetween);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(110_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(110_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_space_between_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceBetween);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_between_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceBetween);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_between_wrapped_negative_space_row_reverse() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::RowReverse);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceBetween);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_between_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceBetween);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_around_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_around_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(15_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(95_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(15_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(95_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_space_around_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_around_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceAround);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_around_wrapped_negative_space_row_reverse() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::RowReverse);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceAround);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_around_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceAround);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_nowrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root_child3.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root_child4.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(23_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(23_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(88_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(23_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(23_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(55_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(55_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(90_f32, root_child4.get_layout_left());
assert_eq!(88_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_wrap_singleline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(140_f32.into()));
root.set_height(StyleUnit::Point(120_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(55_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(55_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(10_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_wrapped_negative_space() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceEvenly);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(20_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(40_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_wrapped_negative_space_gap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 60_f32);
root.set_border(Edge::Top, 60_f32);
root.set_border(Edge::Right, 60_f32);
root.set_border(Edge::Bottom, 60_f32);
root.set_width(StyleUnit::Point(320_f32.into()));
root.set_height(StyleUnit::Point(320_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_justify_content(Justify::Center);
root_child0.set_align_content(Align::SpaceEvenly);
root_child0.set_flex_wrap(Wrap::Wrap);
root_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Column, StyleUnit::Point(10_f32.into()));
root_child0.set_gap(Gutter::Row, StyleUnit::Point(10_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child1, 1);
let mut root_child0_child2 = Node::new_with_config(&mut config);
root_child0_child2.set_width(StyleUnit::Percent(80_f32.into()));
root_child0_child2.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(320_f32, root.get_layout_width());
assert_eq!(320_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(60_f32, root_child0.get_layout_top());
assert_eq!(200_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(160_f32, root_child0_child0.get_layout_width());
assert_eq!(20_f32, root_child0_child0.get_layout_height());
assert_eq!(20_f32, root_child0_child1.get_layout_left());
assert_eq!(30_f32, root_child0_child1.get_layout_top());
assert_eq!(160_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(60_f32, root_child0_child2.get_layout_top());
assert_eq!(160_f32, root_child0_child2.get_layout_width());
assert_eq!(20_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(0_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(0_f32, root_child3.get_layout_height());
assert_eq!(100_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(0_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_children() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_flex_grow(1_f32);
root_child0_child0.set_flex_shrink(1_f32);
root_child0_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(50_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(50_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_flex() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_flex_grow(1_f32);
root_child3.set_flex_shrink(1_f32);
root_child3.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(0_f32, root_child3.get_layout_width());
assert_eq!(100_f32, root_child3.get_layout_height());
assert_eq!(100_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(100_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(0_f32, root_child3.get_layout_width());
assert_eq!(100_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(100_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_flex_no_shrink() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_flex_grow(1_f32);
root_child3.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(0_f32, root_child3.get_layout_width());
assert_eq!(100_f32, root_child3.get_layout_height());
assert_eq!(100_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(100_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(0_f32, root_child3.get_layout_top());
assert_eq!(0_f32, root_child3.get_layout_width());
assert_eq!(100_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(100_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_margin() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_margin(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child1.set_margin(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child1.set_margin(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child1.set_margin(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_margin(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child3.set_margin(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child3.set_margin(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child3.set_margin(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(60_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(40_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(40_f32, root_child2.get_layout_height());
assert_eq!(60_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(20_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(80_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(20_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(40_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(40_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(40_f32, root_child2.get_layout_height());
assert_eq!(40_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(20_f32, root_child3.get_layout_height());
assert_eq!(100_f32, root_child4.get_layout_left());
assert_eq!(80_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(20_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_padding() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child3.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child3.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child3.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(50_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_single_row() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_fixed_height() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(60_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(80_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(60_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(80_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(80_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(20_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(80_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(20_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(80_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(60_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(80_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(80_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(20_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(80_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(20_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_max_height() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_max_height(StyleUnit::Point(20_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(50_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(50_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_row_with_min_height() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(150_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_min_height(StyleUnit::Point(80_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_width(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(90_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(90_f32, root_child1.get_layout_height());
assert_eq!(100_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(90_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(90_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(150_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(90_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(90_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(90_f32, root_child2.get_layout_height());
assert_eq!(100_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(10_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(90_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(10_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_column() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(150_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_flex_grow(1_f32);
root_child0_child0.set_flex_shrink(1_f32);
root_child0_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child3, 3);
let mut root_child4 = Node::new_with_config(&mut config);
root_child4.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child4, 4);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(50_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(50_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(50_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(100_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(50_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(50_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(50_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child2.get_layout_left());
assert_eq!(50_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
assert_eq!(50_f32, root_child3.get_layout_left());
assert_eq!(100_f32, root_child3.get_layout_top());
assert_eq!(50_f32, root_child3.get_layout_width());
assert_eq!(50_f32, root_child3.get_layout_height());
assert_eq!(0_f32, root_child4.get_layout_left());
assert_eq!(0_f32, root_child4.get_layout_top());
assert_eq!(50_f32, root_child4.get_layout_width());
assert_eq!(50_f32, root_child4.get_layout_height());
}
#[test]
fn test_align_content_stretch_is_not_overriding_align_items() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_align_content(Align::Stretch);
root_child0.set_align_items(Align::Center);
root_child0.set_width(StyleUnit::Point(100_f32.into()));
root_child0.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_align_content(Align::Stretch);
root_child0_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(45_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(10_f32, root_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child0_child0.get_layout_left());
assert_eq!(45_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(10_f32, root_child0_child0.get_layout_height());
}
#[test]
fn test_align_content_stretch_with_min_cross_axis() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_min_height(StyleUnit::Point(500_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(500_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(250_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(500_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(250_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_stretch_with_max_cross_axis() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_max_height(StyleUnit::Point(500_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(400_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(400_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_stretch_with_max_cross_axis_and_border_padding() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root.set_border(Edge::Left, 5_f32);
root.set_border(Edge::Top, 5_f32);
root.set_border(Edge::Right, 5_f32);
root.set_border(Edge::Bottom, 5_f32);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_max_height(StyleUnit::Point(500_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(414_f32, root.get_layout_height());
assert_eq!(7_f32, root_child0.get_layout_left());
assert_eq!(7_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(7_f32, root_child1.get_layout_left());
assert_eq!(207_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(414_f32, root.get_layout_height());
assert_eq!(93_f32, root_child0.get_layout_left());
assert_eq!(7_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(93_f32, root_child1.get_layout_left());
assert_eq!(207_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_with_min_cross_axis() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_min_height(StyleUnit::Point(500_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(500_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(33_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(267_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(500_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(33_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(267_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_with_max_cross_axis() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_max_height(StyleUnit::Point(500_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(400_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(400_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_with_max_cross_axis_violated() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_max_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(100_f32, root_child1.get_layout_left());
assert_eq!(200_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_with_max_cross_axis_violated_padding_and_border() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceEvenly);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root.set_border(Edge::Left, 5_f32);
root.set_border(Edge::Top, 5_f32);
root.set_border(Edge::Right, 5_f32);
root.set_border(Edge::Bottom, 5_f32);
root.set_width(StyleUnit::Point(500_f32.into()));
root.set_max_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(400_f32.into()));
root_child0.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(400_f32.into()));
root_child1.set_height(StyleUnit::Point(200_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(7_f32, root_child0.get_layout_left());
assert_eq!(7_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(7_f32, root_child1.get_layout_left());
assert_eq!(207_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(500_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(93_f32, root_child0.get_layout_left());
assert_eq!(7_f32, root_child0.get_layout_top());
assert_eq!(400_f32, root_child0.get_layout_width());
assert_eq!(200_f32, root_child0.get_layout_height());
assert_eq!(93_f32, root_child1.get_layout_left());
assert_eq!(207_f32, root_child1.get_layout_top());
assert_eq!(400_f32, root_child1.get_layout_width());
assert_eq!(200_f32, root_child1.get_layout_height());
}
#[test]
fn test_align_content_space_around_and_align_items_flex_end_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_align_items(Align::FlexEnd);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(88_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(88_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_space_around_and_align_items_center_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_align_items(Align::Center);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(63_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(63_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_space_around_and_align_items_flex_start_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::SpaceAround);
root.set_align_items(Align::FlexStart);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(38_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(38_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_flex_start_stretch_doesnt_influence_line_box_dim() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(20_f32.into()));
root.set_width(StyleUnit::Point(400_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child0.set_width(StyleUnit::Point(100_f32.into()));
root_child0.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_direction(FlexDirection::Row);
root_child1.set_flex_wrap(Wrap::Wrap);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child0.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child0.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child0, 0);
let mut root_child1_child1 = Node::new_with_config(&mut config);
root_child1_child1.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child1.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child1.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child1, 1);
let mut root_child1_child2 = Node::new_with_config(&mut config);
root_child1_child2.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child2.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child2.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child2, 2);
let mut root_child1_child3 = Node::new_with_config(&mut config);
root_child1_child3.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child3.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child3.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child3, 3);
let mut root_child1_child4 = Node::new_with_config(&mut config);
root_child1_child4.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child4.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child4.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child4, 4);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_margin(Edge::Left, StyleUnit::Point(20_f32.into()));
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(140_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(50_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(100_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(0_f32, root_child1_child3.get_layout_left());
assert_eq!(30_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(50_f32, root_child1_child4.get_layout_left());
assert_eq!(30_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(330_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(260_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(70_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(20_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(120_f32, root_child1_child3.get_layout_left());
assert_eq!(30_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(70_f32, root_child1_child4.get_layout_left());
assert_eq!(30_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(40_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch_stretch_does_influence_line_box_dim() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(20_f32.into()));
root.set_width(StyleUnit::Point(400_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child0.set_width(StyleUnit::Point(100_f32.into()));
root_child0.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_direction(FlexDirection::Row);
root_child1.set_align_content(Align::Stretch);
root_child1.set_flex_wrap(Wrap::Wrap);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child0.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child0.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child0, 0);
let mut root_child1_child1 = Node::new_with_config(&mut config);
root_child1_child1.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child1.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child1.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child1, 1);
let mut root_child1_child2 = Node::new_with_config(&mut config);
root_child1_child2.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child2.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child2.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child2, 2);
let mut root_child1_child3 = Node::new_with_config(&mut config);
root_child1_child3.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child3.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child3.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child3, 3);
let mut root_child1_child4 = Node::new_with_config(&mut config);
root_child1_child4.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child4.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child4.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child4, 4);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_margin(Edge::Left, StyleUnit::Point(20_f32.into()));
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(140_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(50_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(100_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(0_f32, root_child1_child3.get_layout_left());
assert_eq!(50_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(50_f32, root_child1_child4.get_layout_left());
assert_eq!(50_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(330_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(260_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(70_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(20_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(120_f32, root_child1_child3.get_layout_left());
assert_eq!(50_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(70_f32, root_child1_child4.get_layout_left());
assert_eq!(50_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(40_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_space_evenly_stretch_does_influence_line_box_dim() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(20_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(20_f32.into()));
root.set_width(StyleUnit::Point(400_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child0.set_width(StyleUnit::Point(100_f32.into()));
root_child0.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_flex_direction(FlexDirection::Row);
root_child1.set_align_content(Align::Stretch);
root_child1.set_flex_wrap(Wrap::Wrap);
root_child1.set_flex_grow(1_f32);
root_child1.set_flex_shrink(1_f32);
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child0.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child0.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child0, 0);
let mut root_child1_child1 = Node::new_with_config(&mut config);
root_child1_child1.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child1.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child1.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child1, 1);
let mut root_child1_child2 = Node::new_with_config(&mut config);
root_child1_child2.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child2.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child2.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child2, 2);
let mut root_child1_child3 = Node::new_with_config(&mut config);
root_child1_child3.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child3.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child3.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child3, 3);
let mut root_child1_child4 = Node::new_with_config(&mut config);
root_child1_child4.set_margin(Edge::Right, StyleUnit::Point(20_f32.into()));
root_child1_child4.set_width(StyleUnit::Point(30_f32.into()));
root_child1_child4.set_height(StyleUnit::Point(30_f32.into()));
root_child1.insert_child(&mut root_child1_child4, 4);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_margin(Edge::Left, StyleUnit::Point(20_f32.into()));
root_child2.set_width(StyleUnit::Point(50_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(140_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(50_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(100_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(0_f32, root_child1_child3.get_layout_left());
assert_eq!(50_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(50_f32, root_child1_child4.get_layout_left());
assert_eq!(50_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(330_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(400_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(260_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(20_f32, root_child1.get_layout_top());
assert_eq!(170_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(30_f32, root_child1_child0.get_layout_width());
assert_eq!(30_f32, root_child1_child0.get_layout_height());
assert_eq!(70_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(30_f32, root_child1_child1.get_layout_width());
assert_eq!(30_f32, root_child1_child1.get_layout_height());
assert_eq!(20_f32, root_child1_child2.get_layout_left());
assert_eq!(0_f32, root_child1_child2.get_layout_top());
assert_eq!(30_f32, root_child1_child2.get_layout_width());
assert_eq!(30_f32, root_child1_child2.get_layout_height());
assert_eq!(120_f32, root_child1_child3.get_layout_left());
assert_eq!(50_f32, root_child1_child3.get_layout_top());
assert_eq!(30_f32, root_child1_child3.get_layout_width());
assert_eq!(30_f32, root_child1_child3.get_layout_height());
assert_eq!(70_f32, root_child1_child4.get_layout_left());
assert_eq!(50_f32, root_child1_child4.get_layout_top());
assert_eq!(30_f32, root_child1_child4.get_layout_width());
assert_eq!(30_f32, root_child1_child4.get_layout_height());
assert_eq!(40_f32, root_child2.get_layout_left());
assert_eq!(20_f32, root_child2.get_layout_top());
assert_eq!(50_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch_and_align_items_flex_end_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_align_items(Align::FlexEnd);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_align_self(Align::FlexStart);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(75_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(250_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(75_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(250_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch_and_align_items_flex_start_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_align_items(Align::FlexStart);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_align_self(Align::FlexEnd);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(175_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(175_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch_and_align_items_center_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_align_items(Align::Center);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_align_self(Align::FlexEnd);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(38_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(213_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}
#[test]
fn test_align_content_stretch_and_align_items_stretch_with_flex_wrap() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
root.set_align_content(Align::Stretch);
root.set_position_type(PositionType::Absolute);
root.set_flex_wrap(Wrap::Wrap);
root.set_width(StyleUnit::Point(300_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_align_self(Align::FlexEnd);
root_child0.set_width(StyleUnit::Point(150_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(120_f32.into()));
root_child1.set_height(StyleUnit::Point(100_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(120_f32.into()));
root_child2.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(150_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(175_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(300_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(150_f32, root_child0.get_layout_left());
assert_eq!(125_f32, root_child0.get_layout_top());
assert_eq!(150_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(120_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(180_f32, root_child2.get_layout_left());
assert_eq!(175_f32, root_child2.get_layout_top());
assert_eq!(120_f32, root_child2.get_layout_width());
assert_eq!(50_f32, root_child2.get_layout_height());
}