extern crate ordered_float;
extern crate yoga;
mod test_utils;
use yoga::*;
#[test]
fn test_box_sizing_content_box_simple() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(130_f32, root.get_layout_width());
assert_eq!(130_f32, root.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!(130_f32, root.get_layout_width());
assert_eq!(130_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_simple() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_content_box_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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(4_f32.into()));
root_child0.set_border(Edge::Left, 16_f32);
root_child0.set_border(Edge::Top, 16_f32);
root_child0.set_border(Edge::Right, 16_f32);
root_child0.set_border(Edge::Bottom, 16_f32);
root_child0.set_width(StyleUnit::Percent(50_f32.into()));
root_child0.set_height(StyleUnit::Percent(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(90_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(90_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_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(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(4_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(4_f32.into()));
root_child0.set_border(Edge::Left, 16_f32);
root_child0.set_border(Edge::Top, 16_f32);
root_child0.set_border(Edge::Right, 16_f32);
root_child0.set_border(Edge::Bottom, 16_f32);
root_child0.set_width(StyleUnit::Percent(50_f32.into()));
root_child0.set_height(StyleUnit::Percent(25_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!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_absolute() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_position_type(PositionType::Absolute);
root_child0.set_padding(Edge::Left, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(12_f32.into()));
root_child0.set_border(Edge::Left, 8_f32);
root_child0.set_border(Edge::Top, 8_f32);
root_child0.set_border(Edge::Right, 8_f32);
root_child0.set_border(Edge::Bottom, 8_f32);
root_child0.set_height(StyleUnit::Percent(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(40_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(40_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_absolute() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_position_type(PositionType::Absolute);
root_child0.set_padding(Edge::Left, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(12_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(12_f32.into()));
root_child0.set_border(Edge::Left, 8_f32);
root_child0.set_border(Edge::Top, 8_f32);
root_child0.set_border(Edge::Right, 8_f32);
root_child0.set_border(Edge::Bottom, 8_f32);
root_child0.set_height(StyleUnit::Percent(25_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!(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!(40_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(60_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(40_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_comtaining_block() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(12_f32.into()));
root.set_border(Edge::Left, 8_f32);
root.set_border(Edge::Top, 8_f32);
root.set_border(Edge::Right, 8_f32);
root.set_border(Edge::Bottom, 8_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_position_type(PositionType::Static);
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_width(StyleUnit::Point(50_f32.into()));
root_child0_child0.set_height(StyleUnit::Percent(25_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(31_f32, root_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(140_f32, root.get_layout_width());
assert_eq!(140_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(31_f32, root_child0_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_comtaining_block() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(12_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(12_f32.into()));
root.set_border(Edge::Left, 8_f32);
root.set_border(Edge::Top, 8_f32);
root.set_border(Edge::Right, 8_f32);
root.set_border(Edge::Bottom, 8_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_position_type(PositionType::Static);
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_width(StyleUnit::Point(50_f32.into()));
root_child0_child0.set_height(StyleUnit::Percent(25_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(60_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child0_child0.get_layout_left());
assert_eq!(0_f32, root_child0_child0.get_layout_top());
assert_eq!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(21_f32, root_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(20_f32, root_child0.get_layout_top());
assert_eq!(60_f32, root_child0.get_layout_width());
assert_eq!(0_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!(50_f32, root_child0_child0.get_layout_width());
assert_eq!(21_f32, root_child0_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_padding_only() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(110_f32, root.get_layout_width());
assert_eq!(110_f32, root.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!(110_f32, root.get_layout_width());
assert_eq!(110_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_padding_only_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(100_f32.into()));
root.set_height(StyleUnit::Point(150_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Percent(10_f32.into()));
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(75_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(70_f32, root_child0.get_layout_width());
assert_eq!(95_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(30_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(70_f32, root_child0.get_layout_width());
assert_eq!(95_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_padding_only() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_border_box_padding_only_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(100_f32.into()));
root.set_height(StyleUnit::Point(150_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Percent(10_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Percent(10_f32.into()));
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(75_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!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(75_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(150_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(75_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_border_only() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(120_f32, root.get_layout_width());
assert_eq!(120_f32, root.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!(120_f32, root.get_layout_width());
assert_eq!(120_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_border_only_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(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::Percent(50_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_border_only() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_border_box_border_only_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(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::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!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(0_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_no_padding_no_border() {
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()));
root.set_box_sizing(BoxSizing::ContentBox);
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());
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());
}
#[test]
fn test_box_sizing_border_box_no_padding_no_border() {
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()));
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());
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());
}
#[test]
fn test_box_sizing_content_box_children() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_width(StyleUnit::Point(25_f32.into()));
root_child0.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child2.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(25_f32.into()));
root_child3.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child3, 3);
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!(130_f32, root.get_layout_width());
assert_eq!(130_f32, root.get_layout_height());
assert_eq!(15_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(15_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
assert_eq!(15_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(15_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.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!(130_f32, root.get_layout_width());
assert_eq!(130_f32, root.get_layout_height());
assert_eq!(90_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(90_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
assert_eq!(90_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(90_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_children() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root.set_border(Edge::Left, 10_f32);
root.set_border(Edge::Top, 10_f32);
root.set_border(Edge::Right, 10_f32);
root.set_border(Edge::Bottom, 10_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(25_f32.into()));
root_child0.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child2.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(25_f32.into()));
root_child3.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child3, 3);
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!(15_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(15_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
assert_eq!(15_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(15_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.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!(60_f32, root_child0.get_layout_left());
assert_eq!(15_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(60_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
assert_eq!(60_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(60_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_siblings() {
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_width(StyleUnit::Point(25_f32.into()));
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child1.set_border(Edge::Left, 10_f32);
root_child1.set_border(Edge::Top, 10_f32);
root_child1.set_border(Edge::Right, 10_f32);
root_child1.set_border(Edge::Bottom, 10_f32);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root_child1.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child1, 1);
let mut root_child2 = Node::new_with_config(&mut config);
root_child2.set_width(StyleUnit::Point(25_f32.into()));
root_child2.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(25_f32.into()));
root_child3.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child3, 3);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(25_f32, root_child1.get_layout_top());
assert_eq!(65_f32, root_child1.get_layout_width());
assert_eq!(65_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(90_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(115_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(75_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(35_f32, root_child1.get_layout_left());
assert_eq!(25_f32, root_child1.get_layout_top());
assert_eq!(65_f32, root_child1.get_layout_width());
assert_eq!(65_f32, root_child1.get_layout_height());
assert_eq!(75_f32, root_child2.get_layout_left());
assert_eq!(90_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(75_f32, root_child3.get_layout_left());
assert_eq!(115_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_siblings() {
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_width(StyleUnit::Point(25_f32.into()));
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_padding(Edge::Left, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Top, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Right, StyleUnit::Point(10_f32.into()));
root_child1.set_padding(Edge::Bottom, StyleUnit::Point(10_f32.into()));
root_child1.set_border(Edge::Left, 10_f32);
root_child1.set_border(Edge::Top, 10_f32);
root_child1.set_border(Edge::Right, 10_f32);
root_child1.set_border(Edge::Bottom, 10_f32);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child2.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child2, 2);
let mut root_child3 = Node::new_with_config(&mut config);
root_child3.set_width(StyleUnit::Point(25_f32.into()));
root_child3.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child3, 3);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(25_f32, root_child1.get_layout_top());
assert_eq!(40_f32, root_child1.get_layout_width());
assert_eq!(40_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(0_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(75_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(25_f32, root_child0.get_layout_width());
assert_eq!(25_f32, root_child0.get_layout_height());
assert_eq!(60_f32, root_child1.get_layout_left());
assert_eq!(25_f32, root_child1.get_layout_top());
assert_eq!(40_f32, root_child1.get_layout_width());
assert_eq!(40_f32, root_child1.get_layout_height());
assert_eq!(75_f32, root_child2.get_layout_left());
assert_eq!(65_f32, root_child2.get_layout_top());
assert_eq!(25_f32, root_child2.get_layout_width());
assert_eq!(25_f32, root_child2.get_layout_height());
assert_eq!(75_f32, root_child3.get_layout_left());
assert_eq!(90_f32, root_child3.get_layout_top());
assert_eq!(25_f32, root_child3.get_layout_width());
assert_eq!(25_f32, root_child3.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_max_width() {
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_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_max_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(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!(90_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(65_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(90_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(65_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_max_width() {
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_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_max_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_max_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()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_max_height(StyleUnit::Point(50_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(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!(90_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(90_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_max_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()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_max_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_min_width() {
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_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_min_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(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!(65_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(65_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(65_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(65_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_min_width() {
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_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_min_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(25_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(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(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!(40_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_min_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()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_min_height(StyleUnit::Point(50_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(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!(90_f32, root_child0.get_layout_width());
assert_eq!(90_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(90_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(10_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(90_f32, root_child0.get_layout_width());
assert_eq!(90_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(90_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_min_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()));
root.set_height(StyleUnit::Point(100_f32.into()));
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 15_f32);
root_child0.set_border(Edge::Top, 15_f32);
root_child0.set_border(Edge::Right, 15_f32);
root_child0.set_border(Edge::Bottom, 15_f32);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_min_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_width(StyleUnit::Point(25_f32.into()));
root_child1.set_height(StyleUnit::Point(25_f32.into()));
root.insert_child(&mut root_child1, 1);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(50_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
assert_eq!(75_f32, root_child1.get_layout_left());
assert_eq!(50_f32, root_child1.get_layout_top());
assert_eq!(25_f32, root_child1.get_layout_width());
assert_eq!(25_f32, root_child1.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_no_height_no_width() {
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_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root_child0.set_border(Edge::Left, 7_f32);
root_child0.set_border(Edge::Top, 7_f32);
root_child0.set_border(Edge::Right, 7_f32);
root_child0.set_border(Edge::Bottom, 7_f32);
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(18_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(18_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_no_height_no_width() {
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_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root_child0.set_border(Edge::Left, 7_f32);
root_child0.set_border(Edge::Top, 7_f32);
root_child0.set_border(Edge::Right, 7_f32);
root_child0.set_border(Edge::Bottom, 7_f32);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(18_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(18_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_nested() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(15_f32.into()));
root.set_border(Edge::Left, 3_f32);
root.set_border(Edge::Top, 3_f32);
root.set_border(Edge::Right, 3_f32);
root.set_border(Edge::Bottom, 3_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root_child0.set_border(Edge::Left, 7_f32);
root_child0.set_border(Edge::Top, 7_f32);
root_child0.set_border(Edge::Right, 7_f32);
root_child0.set_border(Edge::Bottom, 7_f32);
root_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0.set_height(StyleUnit::Point(20_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_padding(Edge::Left, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Top, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Right, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_border(Edge::Left, 2_f32);
root_child0_child0.set_border(Edge::Top, 2_f32);
root_child0_child0.set_border(Edge::Right, 2_f32);
root_child0_child0.set_border(Edge::Bottom, 2_f32);
root_child0_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(5_f32.into()));
root_child0_child0.set_box_sizing(BoxSizing::ContentBox);
root_child0.insert_child(&mut root_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(136_f32, root.get_layout_width());
assert_eq!(136_f32, root.get_layout_height());
assert_eq!(18_f32, root_child0.get_layout_left());
assert_eq!(18_f32, root_child0.get_layout_top());
assert_eq!(38_f32, root_child0.get_layout_width());
assert_eq!(38_f32, root_child0.get_layout_height());
assert_eq!(9_f32, root_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0.get_layout_top());
assert_eq!(16_f32, root_child0_child0.get_layout_width());
assert_eq!(11_f32, root_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(136_f32, root.get_layout_width());
assert_eq!(136_f32, root.get_layout_height());
assert_eq!(80_f32, root_child0.get_layout_left());
assert_eq!(18_f32, root_child0.get_layout_top());
assert_eq!(38_f32, root_child0.get_layout_width());
assert_eq!(38_f32, root_child0.get_layout_height());
assert_eq!(13_f32, root_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0.get_layout_top());
assert_eq!(16_f32, root_child0_child0.get_layout_width());
assert_eq!(11_f32, root_child0_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_nested() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(15_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(15_f32.into()));
root.set_border(Edge::Left, 3_f32);
root.set_border(Edge::Top, 3_f32);
root.set_border(Edge::Right, 3_f32);
root.set_border(Edge::Bottom, 3_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_padding(Edge::Left, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(2_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(2_f32.into()));
root_child0.set_border(Edge::Left, 7_f32);
root_child0.set_border(Edge::Top, 7_f32);
root_child0.set_border(Edge::Right, 7_f32);
root_child0.set_border(Edge::Bottom, 7_f32);
root_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0.set_height(StyleUnit::Point(20_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_padding(Edge::Left, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Top, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Right, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(1_f32.into()));
root_child0_child0.set_border(Edge::Left, 2_f32);
root_child0_child0.set_border(Edge::Top, 2_f32);
root_child0_child0.set_border(Edge::Right, 2_f32);
root_child0_child0.set_border(Edge::Bottom, 2_f32);
root_child0_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(5_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(18_f32, root_child0.get_layout_left());
assert_eq!(18_f32, root_child0.get_layout_top());
assert_eq!(20_f32, root_child0.get_layout_width());
assert_eq!(20_f32, root_child0.get_layout_height());
assert_eq!(9_f32, root_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(6_f32, root_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(62_f32, root_child0.get_layout_left());
assert_eq!(18_f32, root_child0.get_layout_top());
assert_eq!(20_f32, root_child0.get_layout_width());
assert_eq!(20_f32, root_child0.get_layout_height());
assert_eq!(1_f32, root_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0.get_layout_width());
assert_eq!(6_f32, root_child0_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_nested_alternating() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(3_f32.into()));
root.set_border(Edge::Left, 2_f32);
root.set_border(Edge::Top, 2_f32);
root.set_border(Edge::Right, 2_f32);
root.set_border(Edge::Bottom, 2_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
let mut root_child0 = Node::new_with_config(&mut config);
root_child0.set_padding(Edge::Left, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(8_f32.into()));
root_child0.set_border(Edge::Left, 2_f32);
root_child0.set_border(Edge::Top, 2_f32);
root_child0.set_border(Edge::Right, 2_f32);
root_child0.set_border(Edge::Bottom, 2_f32);
root_child0.set_width(StyleUnit::Point(40_f32.into()));
root_child0.set_height(StyleUnit::Point(40_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_padding(Edge::Left, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Top, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Right, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_border(Edge::Left, 6_f32);
root_child0_child0.set_border(Edge::Top, 6_f32);
root_child0_child0.set_border(Edge::Right, 6_f32);
root_child0_child0.set_border(Edge::Bottom, 6_f32);
root_child0_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0_child0.set_box_sizing(BoxSizing::ContentBox);
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0_child0.set_padding(Edge::Left, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Top, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Right, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_border(Edge::Left, 1_f32);
root_child0_child0_child0.set_border(Edge::Top, 1_f32);
root_child0_child0_child0.set_border(Edge::Right, 1_f32);
root_child0_child0_child0.set_border(Edge::Bottom, 1_f32);
root_child0_child0_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0_child0_child0.set_height(StyleUnit::Point(5_f32.into()));
root_child0_child0.insert_child(&mut root_child0_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(110_f32, root.get_layout_width());
assert_eq!(110_f32, root.get_layout_height());
assert_eq!(5_f32, root_child0.get_layout_left());
assert_eq!(5_f32, root_child0.get_layout_top());
assert_eq!(40_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(10_f32, root_child0_child0.get_layout_top());
assert_eq!(38_f32, root_child0_child0.get_layout_width());
assert_eq!(43_f32, root_child0_child0.get_layout_height());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(5_f32, root_child0_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(110_f32, root.get_layout_width());
assert_eq!(110_f32, root.get_layout_height());
assert_eq!(65_f32, root_child0.get_layout_left());
assert_eq!(5_f32, root_child0.get_layout_top());
assert_eq!(40_f32, root_child0.get_layout_width());
assert_eq!(40_f32, root_child0.get_layout_height());
assert_eq!(-8_f32, root_child0_child0.get_layout_left());
assert_eq!(10_f32, root_child0_child0.get_layout_top());
assert_eq!(38_f32, root_child0_child0.get_layout_width());
assert_eq!(43_f32, root_child0_child0.get_layout_height());
assert_eq!(19_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(10_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(5_f32, root_child0_child0_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_nested_alternating() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Left, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Top, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Right, StyleUnit::Point(3_f32.into()));
root.set_padding(Edge::Bottom, StyleUnit::Point(3_f32.into()));
root.set_border(Edge::Left, 2_f32);
root.set_border(Edge::Top, 2_f32);
root.set_border(Edge::Right, 2_f32);
root.set_border(Edge::Bottom, 2_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_padding(Edge::Left, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(8_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(8_f32.into()));
root_child0.set_border(Edge::Left, 2_f32);
root_child0.set_border(Edge::Top, 2_f32);
root_child0.set_border(Edge::Right, 2_f32);
root_child0.set_border(Edge::Bottom, 2_f32);
root_child0.set_width(StyleUnit::Point(40_f32.into()));
root_child0.set_height(StyleUnit::Point(40_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
let mut root_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0.set_padding(Edge::Left, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Top, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Right, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(3_f32.into()));
root_child0_child0.set_border(Edge::Left, 6_f32);
root_child0_child0.set_border(Edge::Top, 6_f32);
root_child0_child0.set_border(Edge::Right, 6_f32);
root_child0_child0.set_border(Edge::Bottom, 6_f32);
root_child0_child0.set_width(StyleUnit::Point(20_f32.into()));
root_child0_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0.insert_child(&mut root_child0_child0, 0);
let mut root_child0_child0_child0 = Node::new_with_config(&mut config);
root_child0_child0_child0.set_padding(Edge::Left, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Top, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Right, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_padding(Edge::Bottom, StyleUnit::Point(1_f32.into()));
root_child0_child0_child0.set_border(Edge::Left, 1_f32);
root_child0_child0_child0.set_border(Edge::Top, 1_f32);
root_child0_child0_child0.set_border(Edge::Right, 1_f32);
root_child0_child0_child0.set_border(Edge::Bottom, 1_f32);
root_child0_child0_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0_child0_child0.set_height(StyleUnit::Point(5_f32.into()));
root_child0_child0_child0.set_box_sizing(BoxSizing::ContentBox);
root_child0_child0.insert_child(&mut root_child0_child0_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(5_f32, root_child0.get_layout_left());
assert_eq!(5_f32, root_child0.get_layout_top());
assert_eq!(60_f32, root_child0.get_layout_width());
assert_eq!(60_f32, root_child0.get_layout_height());
assert_eq!(10_f32, root_child0_child0.get_layout_left());
assert_eq!(10_f32, root_child0_child0.get_layout_top());
assert_eq!(20_f32, root_child0_child0.get_layout_width());
assert_eq!(25_f32, root_child0_child0.get_layout_height());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(14_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(35_f32, root_child0.get_layout_left());
assert_eq!(5_f32, root_child0.get_layout_top());
assert_eq!(60_f32, root_child0.get_layout_width());
assert_eq!(60_f32, root_child0.get_layout_height());
assert_eq!(30_f32, root_child0_child0.get_layout_left());
assert_eq!(10_f32, root_child0_child0.get_layout_top());
assert_eq!(20_f32, root_child0_child0.get_layout_width());
assert_eq!(25_f32, root_child0_child0.get_layout_height());
assert_eq!(-3_f32, root_child0_child0_child0.get_layout_left());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_top());
assert_eq!(14_f32, root_child0_child0_child0.get_layout_width());
assert_eq!(9_f32, root_child0_child0_child0.get_layout_height());
}
#[test]
#[ignore]
fn test_box_sizing_content_box_flex_basis_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_flex_basis(StyleUnit::Point(50_f32.into()));
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 10_f32);
root_child0.set_border(Edge::Top, 10_f32);
root_child0.set_border(Edge::Right, 10_f32);
root_child0.set_border(Edge::Bottom, 10_f32);
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(80_f32, root_child0.get_layout_width());
assert_eq!(55_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(20_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(80_f32, root_child0.get_layout_width());
assert_eq!(55_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_flex_basis_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_flex_basis(StyleUnit::Point(50_f32.into()));
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 10_f32);
root_child0.set_border(Edge::Top, 10_f32);
root_child0.set_border(Edge::Right, 10_f32);
root_child0.set_border(Edge::Bottom, 10_f32);
root_child0.set_height(StyleUnit::Point(25_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!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(30_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(50_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(50_f32, root_child0.get_layout_width());
assert_eq!(30_f32, root_child0.get_layout_height());
}
#[test]
#[ignore]
fn test_box_sizing_content_box_flex_basis_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_flex_basis(StyleUnit::Point(50_f32.into()));
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 10_f32);
root_child0.set_border(Edge::Top, 10_f32);
root_child0.set_border(Edge::Right, 10_f32);
root_child0.set_border(Edge::Bottom, 10_f32);
root_child0.set_height(StyleUnit::Point(25_f32.into()));
root_child0.set_box_sizing(BoxSizing::ContentBox);
root.insert_child(&mut root_child0, 0);
root.calculate_layout(Undefined, Undefined, Direction::LTR);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(80_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(80_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_flex_basis_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_flex_basis(StyleUnit::Point(50_f32.into()));
root_child0.set_padding(Edge::Left, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Top, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Right, StyleUnit::Point(5_f32.into()));
root_child0.set_padding(Edge::Bottom, StyleUnit::Point(5_f32.into()));
root_child0.set_border(Edge::Left, 10_f32);
root_child0.set_border(Edge::Top, 10_f32);
root_child0.set_border(Edge::Right, 10_f32);
root_child0.set_border(Edge::Bottom, 10_f32);
root_child0.set_height(StyleUnit::Point(25_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!(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!(50_f32, root_child0.get_layout_height());
root.calculate_layout(Undefined, Undefined, Direction::RTL);
assert_eq!(0_f32, root.get_layout_left());
assert_eq!(0_f32, root.get_layout_top());
assert_eq!(100_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
assert_eq!(0_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(100_f32, root_child0.get_layout_width());
assert_eq!(50_f32, root_child0.get_layout_height());
}
#[test]
fn test_box_sizing_content_box_padding_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Start, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_padding_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::Start, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_content_box_padding_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::End, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_padding_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_padding(Edge::End, StyleUnit::Point(5_f32.into()));
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_content_box_border_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Start, 5_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_border_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::Start, 5_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}
#[test]
fn test_box_sizing_content_box_border_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::End, 5_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
root.set_box_sizing(BoxSizing::ContentBox);
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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.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!(105_f32, root.get_layout_width());
assert_eq!(100_f32, root.get_layout_height());
}
#[test]
fn test_box_sizing_border_box_border_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_position_type(PositionType::Absolute);
root.set_border(Edge::End, 5_f32);
root.set_width(StyleUnit::Point(100_f32.into()));
root.set_height(StyleUnit::Point(100_f32.into()));
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());
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());
}