extern crate ordered_float;
extern crate yoga;
mod test_utils;
use yoga::*;
#[test]
fn test_display_none() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
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_display(Display::None);
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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
}
#[test]
fn test_display_none_fixed_size() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(20_f32.into()));
root_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child1.set_display(Display::None);
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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
}
#[test]
fn test_display_none_with_margin() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_margin(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.set_display(Display::None);
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.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!(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!(0_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!(100_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!(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!(0_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!(100_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
}
#[test]
fn test_display_none_with_child() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
root_child0.set_flex_shrink(1_f32);
root_child0.set_flex_basis(StyleUnit::Percent(0_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_display(Display::None);
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_flex_grow(1_f32);
root_child1_child0.set_flex_shrink(1_f32);
root_child1_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child1.insert_child(&mut root_child1_child0, 0);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_flex_grow(1_f32);
root_child2.set_flex_shrink(1_f32);
root_child2.set_flex_basis(StyleUnit::Percent(0_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!(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!(100_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!(0_f32, root_child1.get_layout_width());
assert_eq!(0_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!(0_f32, root_child1_child0.get_layout_width());
assert_eq!(0_f32, root_child1_child0.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());
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!(100_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!(0_f32, root_child1.get_layout_width());
assert_eq!(0_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!(0_f32, root_child1_child0.get_layout_width());
assert_eq!(0_f32, root_child1_child0.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!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_display_none_with_position() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
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_position(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child1.set_display(Display::None);
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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_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!(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_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(0_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
}
#[test]
fn test_display_none_with_position_absolute() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
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_position_type(PositionType::Absolute);
root_child0.set_width(StyleUnit::Point(100_f32.into()));
root_child0.set_height(StyleUnit::Point(100_f32.into()));
root_child0.set_display(Display::None);
root.insert_child(&mut root_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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
}
#[test]
fn test_display_contents() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_display(Display::Contents);
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_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child0_child1.set_flex_shrink(1_f32);
root_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_fixed_size() {
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(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_child0.set_height(StyleUnit::Point(50_f32.into()));
root_child0.set_display(Display::Contents);
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_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child0_child1.set_flex_shrink(1_f32);
root_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_with_margin() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_margin(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child0.set_margin(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.set_display(Display::Contents);
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.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!(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!(0_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!(100_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!(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!(0_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!(100_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
}
#[test]
fn test_display_contents_with_padding() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child0.set_display(Display::Contents);
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_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child0_child1.set_flex_shrink(1_f32);
root_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_with_position() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_position(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child0.set_display(Display::Contents);
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_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child0_child1.set_flex_shrink(1_f32);
root_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_with_position_absolute() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_position_type(PositionType::Absolute);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root_child0.set_display(Display::Contents);
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_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child0_child1.set_flex_shrink(1_f32);
root_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0.insert_child(&mut root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_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!(10_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_nested() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_display(Display::Contents);
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_display(Display::Contents);
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0_child0.set_flex_grow(1_f32);
root_child0_child0_child0.set_flex_shrink(1_f32);
root_child0_child0_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child0_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child0_child0.insert_child(&mut root_child0_child0_child0, 0);
let mut root_child0_child0_child1 = Node::new_with_config(&mut config);
root_child0_child0_child1.set_flex_grow(1_f32);
root_child0_child0_child1.set_flex_shrink(1_f32);
root_child0_child0_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0_child0_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child0_child0.insert_child(&mut root_child0_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(0_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(10_f32, root_child0_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child0_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!(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!(0_f32, root_child0.get_layout_width());
assert_eq!(0_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!(0_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(10_f32, root_child0_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child0_child1.get_layout_top());
assert_eq!(50_f32, root_child0_child0_child1.get_layout_width());
assert_eq!(20_f32, root_child0_child0_child1.get_layout_height());
}
#[test]
fn test_display_contents_with_siblings() {
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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_grow(1_f32);
root_child0.set_flex_shrink(1_f32);
root_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child0.set_height(StyleUnit::Point(30_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_display(Display::Contents);
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_flex_grow(1_f32);
root_child1_child0.set_flex_shrink(1_f32);
root_child1_child0.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1_child0.set_height(StyleUnit::Point(10_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_flex_grow(1_f32);
root_child1_child1.set_flex_shrink(1_f32);
root_child1_child1.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child1_child1.set_height(StyleUnit::Point(20_f32.into()));
root_child1.insert_child(&mut root_child1_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_flex_grow(1_f32);
root_child2.set_flex_shrink(1_f32);
root_child2.set_flex_basis(StyleUnit::Percent(0_f32.into()));
root_child2.set_height(StyleUnit::Point(30_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!(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!(25_f32, root_child0.get_layout_width());
assert_eq!(30_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!(0_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(25_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(25_f32, root_child1_child0.get_layout_width());
assert_eq!(10_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!(25_f32, root_child1_child1.get_layout_width());
assert_eq!(20_f32, root_child1_child1.get_layout_height());
assert_eq!(75_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(30_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!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(75_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(30_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!(0_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(50_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(25_f32, root_child1_child0.get_layout_width());
assert_eq!(10_f32, root_child1_child0.get_layout_height());
assert_eq!(25_f32, root_child1_child1.get_layout_left());
assert_eq!(0_f32, root_child1_child1.get_layout_top());
assert_eq!(25_f32, root_child1_child1.get_layout_width());
assert_eq!(20_f32, root_child1_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(30_f32, root_child2.get_layout_height());
}