extern crate ordered_float;
extern crate yoga;
mod test_utils;
use yoga::*;
#[test]
fn test_flex_direction_column_no_height() {
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()));
let mut root_child0 = Node::new_with_config(&mut config);
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_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_height(StyleUnit::Point(10_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!(30_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!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(100_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!(20_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_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!(30_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!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(100_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!(20_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_no_width() {
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_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(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(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(10_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!(30_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!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(30_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_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!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column() {
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_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_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_height(StyleUnit::Point(10_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!(100_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(100_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!(20_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_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!(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!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(10_f32, root_child1.get_layout_top());
assert_eq!(100_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!(20_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row() {
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(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(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(10_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!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
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_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_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_height(StyleUnit::Point(10_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!(90_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(80_f32, root_child1.get_layout_top());
assert_eq!(100_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!(70_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(90_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(80_f32, root_child1.get_layout_top());
assert_eq!(100_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!(70_f32, root_child2.get_layout_top());
assert_eq!(100_f32, root_child2.get_layout_width());
assert_eq!(10_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_margin_left() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::Left, StyleUnit::Point(100_f32.into()));
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(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(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(10_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(100_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(100_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!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_margin_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::Start, StyleUnit::Point(100_f32.into()));
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(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(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(10_f32.into()));
root.insert_child(&mut root_child2, 2);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(100_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_margin_right() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::Right, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_margin_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::End, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(100_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!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_margin_top() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::Top, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(100_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!(100_f32, root_child0.get_layout_top());
assert_eq!(10_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!(100_f32, root_child1.get_layout_top());
assert_eq!(10_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!(100_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(100_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(100_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(100_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_margin_bottom() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_margin(Edge::Bottom, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(100_f32, root_child0.get_layout_top());
assert_eq!(10_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!(100_f32, root_child1.get_layout_top());
assert_eq!(10_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!(100_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_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!(90_f32, root_child0.get_layout_left());
assert_eq!(100_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(100_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_padding_left() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(110_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_padding_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Start, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_padding_right() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Right, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(-10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(-20_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(-30_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_padding_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::End, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(-10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(-20_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(-30_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(110_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_padding_top() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Top, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(100_f32, root_child0.get_layout_top());
assert_eq!(10_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!(100_f32, root_child1.get_layout_top());
assert_eq!(10_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!(100_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_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!(90_f32, root_child0.get_layout_left());
assert_eq!(100_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(100_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_padding_bottom() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Bottom, StyleUnit::Point(100_f32.into()));
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(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(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(10_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!(10_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!(10_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_border_left() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 100_f32);
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(110_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_border_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Start, 100_f32);
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(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(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(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(80_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(70_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_border_right() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Right, 100_f32);
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(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(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(10_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!(-10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(-20_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(-30_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(20_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_border_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::RowReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::End, 100_f32);
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(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(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(10_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!(-10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(-20_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(-30_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_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!(100_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(100_f32, root_child0.get_layout_height());
assert_eq!(110_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(100_f32, root_child1.get_layout_height());
assert_eq!(120_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(100_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_border_top() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Top, 100_f32);
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(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(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(10_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!(100_f32, root_child0.get_layout_top());
assert_eq!(10_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!(100_f32, root_child1.get_layout_top());
assert_eq!(10_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!(100_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_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!(90_f32, root_child0.get_layout_left());
assert_eq!(100_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(100_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_border_bottom() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::ColumnReverse);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Bottom, 100_f32);
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(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(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(10_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!(10_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!(10_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!(10_f32, root_child2.get_layout_width());
assert_eq!(0_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(0_f32, root_child1.get_layout_top());
assert_eq!(10_f32, root_child1.get_layout_width());
assert_eq!(0_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(0_f32, root_child2.get_layout_top());
assert_eq!(10_f32, root_child2.get_layout_width());
assert_eq!(0_f32, root_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_pos_left() {
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_flex_direction(FlexDirection::RowReverse);
root_child0.set_position(Edge::Left, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(80_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(70_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_pos_start() {
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_flex_direction(FlexDirection::RowReverse);
root_child0.set_position(Edge::Start, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(80_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(70_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_pos_right() {
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_flex_direction(FlexDirection::RowReverse);
root_child0.set_position(Edge::Right, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(80_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(70_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_pos_end() {
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_flex_direction(FlexDirection::RowReverse);
root_child0.set_position(Edge::End, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(80_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(70_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(100_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!(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!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(100_f32, root_child0_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(20_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_pos_top() {
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_flex_direction(FlexDirection::ColumnReverse);
root_child0.set_position(Edge::Top, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(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!(100_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!(100_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(100_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!(100_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_column_reverse_pos_bottom() {
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_flex_direction(FlexDirection::ColumnReverse);
root_child0.set_position(Edge::Bottom, StyleUnit::Point(100_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_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_width(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_width(StyleUnit::Point(10_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::Point(10_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!(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!(-100_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!(100_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(-100_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!(100_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(0_f32, root_child0_child0.get_layout_height());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_pos_left() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::Left, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_pos_right() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::Right, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_pos_top() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::Top, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(10_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(10_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_pos_bottom() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::Bottom, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(80_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
#[ignore]
fn test_flex_direction_row_reverse_inner_pos_start() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::Start, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
#[ignore]
fn test_flex_direction_row_reverse_inner_pos_end() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_position(Edge::End, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_margin_left() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::Left, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_margin_right() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::Right, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_margin_top() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::Top, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(90_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(90_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_margin_bottom() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::Bottom, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(80_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_marign_start() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::Start, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_margin_end() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_margin(Edge::End, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(80_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_border_left() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Left, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_border_right() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Right, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_border_top() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Top, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(90_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(90_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_border_bottom() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Bottom, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(90_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(90_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_border_start() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Left, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_border_end() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_border(Edge::Right, 10_f32);
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_padding_left() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_padding_right() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_padding_top() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(90_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(90_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_col_reverse_inner_padding_bottom() {
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_flex_direction(FlexDirection::ColumnReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(90_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(0_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_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!(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!(90_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(100_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(0_f32, root_child0_child1.get_layout_height());
assert_eq!(90_f32, root_child0_child2.get_layout_left());
assert_eq!(100_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(0_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_padding_start() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::Start, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_row_reverse_inner_padding_end() {
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_flex_direction(FlexDirection::RowReverse);
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_position_type(PositionType::Absolute);
root_child0_child0.set_padding(Edge::End, StyleUnit::Point(10_f32.into()));
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);
let mut root_child0_child1 = Node::new_with_config(&mut config);
root_child0_child1.set_width(StyleUnit::Point(10_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::Point(10_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!(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!(0_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());
assert_eq!(90_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(80_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_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!(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!(0_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());
assert_eq!(0_f32, root_child0_child1.get_layout_left());
assert_eq!(0_f32, root_child0_child1.get_layout_top());
assert_eq!(10_f32, root_child0_child1.get_layout_width());
assert_eq!(100_f32, root_child0_child1.get_layout_height());
assert_eq!(10_f32, root_child0_child2.get_layout_left());
assert_eq!(0_f32, root_child0_child2.get_layout_top());
assert_eq!(10_f32, root_child0_child2.get_layout_width());
assert_eq!(100_f32, root_child0_child2.get_layout_height());
}
#[test]
fn test_flex_direction_alternating_with_percent() {
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(200_f32.into()));
root.set_height(StyleUnit::Point(300_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_flex_direction(FlexDirection::Row);
root_child0.set_position(Edge::Left, StyleUnit::Percent(10_f32.into()));
root_child0.set_position(Edge::Top, StyleUnit::Percent(10_f32.into()));
root_child0.set_width(StyleUnit::Percent(50_f32.into()));
root_child0.set_height(StyleUnit::Percent(50_f32.into()));
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!(200_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(30_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(150_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!(200_f32, root.get_layout_width());
assert_eq!(300_f32, root.get_layout_height());
assert_eq!(120_f32, root_child0.get_layout_left());
assert_eq!(30_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(150_f32, root_child0.get_layout_height());
}