extern crate ordered_float;
extern crate yoga;
use yoga::*;
#[test]
fn test_align_self_center() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
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_align_self(Align::Center);
root_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0.set_height(StyleUnit::Point(10_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!(45_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(10_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!(45_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
}
#[test]
fn test_align_self_flex_end() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
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_align_self(Align::FlexEnd);
root_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0.set_height(StyleUnit::Point(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(10_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!(10_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
}
#[test]
fn test_align_self_flex_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
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_align_self(Align::FlexStart);
root_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0.set_height(StyleUnit::Point(10_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!(10_f32, root_child0.get_layout_width());
assert_eq!(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
}
#[test]
fn test_align_self_flex_end_override_flex_start() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_align_items(Align::FlexStart);
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_align_self(Align::FlexEnd);
root_child0.set_width(StyleUnit::Point(10_f32.into()));
root_child0.set_height(StyleUnit::Point(10_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!(90_f32, root_child0.get_layout_left());
assert_eq!(0_f32, root_child0.get_layout_top());
assert_eq!(10_f32, root_child0.get_layout_width());
assert_eq!(10_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!(10_f32, root_child0.get_layout_width());
assert_eq!(10_f32, root_child0.get_layout_height());
}
#[test]
fn test_align_self_baseline() {
let mut config = Config::new();
let mut root = Node::new_with_config(&mut config);
root.set_flex_direction(FlexDirection::Row);
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_align_self(Align::Baseline);
root_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child0.set_height(StyleUnit::Point(50_f32.into()));
root.insert_child(&mut root_child0, 0);
let mut root_child1 = Node::new_with_config(&mut config);
root_child1.set_align_self(Align::Baseline);
root_child1.set_width(StyleUnit::Point(50_f32.into()));
root_child1.set_height(StyleUnit::Point(20_f32.into()));
root.insert_child(&mut root_child1, 1);
let mut root_child1_child0 = Node::new_with_config(&mut config);
root_child1_child0.set_width(StyleUnit::Point(50_f32.into()));
root_child1_child0.set_height(StyleUnit::Point(10_f32.into()));
root_child1.insert_child(&mut root_child1_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!(50_f32, root_child0.get_layout_height());
assert_eq!(50_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(50_f32, root_child1_child0.get_layout_width());
assert_eq!(10_f32, root_child1_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!(50_f32, root_child0.get_layout_height());
assert_eq!(0_f32, root_child1.get_layout_left());
assert_eq!(40_f32, root_child1.get_layout_top());
assert_eq!(50_f32, root_child1.get_layout_width());
assert_eq!(20_f32, root_child1.get_layout_height());
assert_eq!(0_f32, root_child1_child0.get_layout_left());
assert_eq!(0_f32, root_child1_child0.get_layout_top());
assert_eq!(50_f32, root_child1_child0.get_layout_width());
assert_eq!(10_f32, root_child1_child0.get_layout_height());
}