/** * Copyright (c) 2014-present, Facebook, Inc. * * This source code is licensed under the MIT license found in the * LICENSE file in the root directory of this source tree. */ // @Generated by gentest/gentest.rb from gentest/fixtures/YGJustifyContentTest.html extern crate ordered_float; extern crate yoga; use yoga::*; #[test] fn test_justify_content_row_flex_start() { 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((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((10 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_width(StyleUnit::Point((10 as f32).into())); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_width(StyleUnit::Point((10 as f32).into())); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(10 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(20 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(92 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(82 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(72 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_flex_end() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::FlexEnd); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((10 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_width(StyleUnit::Point((10 as f32).into())); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_width(StyleUnit::Point((10 as f32).into())); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(72 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(82 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(92 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(20 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(10 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_center() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::Center); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((10 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_width(StyleUnit::Point((10 as f32).into())); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_width(StyleUnit::Point((10 as f32).into())); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(36 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(56 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(56 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(36 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_space_between() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::SpaceBetween); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((10 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_width(StyleUnit::Point((10 as f32).into())); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_width(StyleUnit::Point((10 as f32).into())); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(92 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(92 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_space_around() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::SpaceAround); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((10 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_width(StyleUnit::Point((10 as f32).into())); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_width(StyleUnit::Point((10 as f32).into())); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(12 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(80 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(80 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(10 as f32, root_child0.get_layout_width()); assert_eq!(102 as f32, root_child0.get_layout_height()); assert_eq!(46 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(10 as f32, root_child1.get_layout_width()); assert_eq!(102 as f32, root_child1.get_layout_height()); assert_eq!(12 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(10 as f32, root_child2.get_layout_width()); assert_eq!(102 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_column_flex_start() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(10 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(20 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(10 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(20 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_column_flex_end() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::FlexEnd); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(72 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(82 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(92 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(72 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(82 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(92 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_column_center() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::Center); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(36 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(56 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(36 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(56 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_column_space_between() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::SpaceBetween); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(92 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(92 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_column_space_around() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::SpaceAround); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(12 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(80 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(12 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(80 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_min_width_and_margin() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::Center); root.set_margin(Edge::Left, StyleUnit::Point((100 as f32).into())); root.set_min_width(StyleUnit::Point((50 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((20 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((20 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(100 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(50 as f32, root.get_layout_width()); assert_eq!(20 as f32, root.get_layout_height()); assert_eq!(15 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(100 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(50 as f32, root.get_layout_width()); assert_eq!(20 as f32, root.get_layout_height()); assert_eq!(15 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); } #[test] fn test_justify_content_row_max_width_and_margin() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::Center); root.set_margin(Edge::Left, StyleUnit::Point((100 as f32).into())); root.set_width(StyleUnit::Point((100 as f32).into())); root.set_max_width(StyleUnit::Point((80 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((20 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((20 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(100 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(80 as f32, root.get_layout_width()); assert_eq!(20 as f32, root.get_layout_height()); assert_eq!(30 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(100 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(80 as f32, root.get_layout_width()); assert_eq!(20 as f32, root.get_layout_height()); assert_eq!(30 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); } #[test] fn test_justify_content_column_min_height_and_margin() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::Center); root.set_margin(Edge::Top, StyleUnit::Point((100 as f32).into())); root.set_min_height(StyleUnit::Point((50 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((20 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((20 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(100 as f32, root.get_layout_top()); assert_eq!(20 as f32, root.get_layout_width()); assert_eq!(50 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(15 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(100 as f32, root.get_layout_top()); assert_eq!(20 as f32, root.get_layout_width()); assert_eq!(50 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(15 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); } #[test] fn test_justify_content_colunn_max_height_and_margin() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::Center); root.set_margin(Edge::Top, StyleUnit::Point((100 as f32).into())); root.set_height(StyleUnit::Point((100 as f32).into())); root.set_max_height(StyleUnit::Point((80 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_width(StyleUnit::Point((20 as f32).into())); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((20 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(100 as f32, root.get_layout_top()); assert_eq!(20 as f32, root.get_layout_width()); assert_eq!(80 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(30 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(100 as f32, root.get_layout_top()); assert_eq!(20 as f32, root.get_layout_width()); assert_eq!(80 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(30 as f32, root_child0.get_layout_top()); assert_eq!(20 as f32, root_child0.get_layout_width()); assert_eq!(20 as f32, root_child0.get_layout_height()); } #[test] fn test_justify_content_column_space_evenly() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_justify_content(Justify::SpaceEvenly); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(18 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(74 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(18 as f32, root_child0.get_layout_top()); assert_eq!(102 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child1.get_layout_left()); assert_eq!(46 as f32, root_child1.get_layout_top()); assert_eq!(102 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(0 as f32, root_child2.get_layout_left()); assert_eq!(74 as f32, root_child2.get_layout_top()); assert_eq!(102 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_row_space_evenly() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_flex_direction(FlexDirection::Row); root.set_justify_content(Justify::SpaceEvenly); root.set_width(StyleUnit::Point((102 as f32).into())); root.set_height(StyleUnit::Point((102 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_height(StyleUnit::Point((10 as f32).into())); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child1 = Node::new_with_config(&mut config); root_child1.set_min_width(StyleUnit::Auto); root_child1.set_height(StyleUnit::Point((10 as f32).into())); root_child1.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child1, 1); let mut root_child2 = Node::new_with_config(&mut config); root_child2.set_min_width(StyleUnit::Auto); root_child2.set_height(StyleUnit::Point((10 as f32).into())); root_child2.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child2, 2); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(26 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(0 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(51 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(0 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(77 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(0 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(102 as f32, root.get_layout_width()); assert_eq!(102 as f32, root.get_layout_height()); assert_eq!(77 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(0 as f32, root_child0.get_layout_width()); assert_eq!(10 as f32, root_child0.get_layout_height()); assert_eq!(51 as f32, root_child1.get_layout_left()); assert_eq!(0 as f32, root_child1.get_layout_top()); assert_eq!(0 as f32, root_child1.get_layout_width()); assert_eq!(10 as f32, root_child1.get_layout_height()); assert_eq!(26 as f32, root_child2.get_layout_left()); assert_eq!(0 as f32, root_child2.get_layout_top()); assert_eq!(0 as f32, root_child2.get_layout_width()); assert_eq!(10 as f32, root_child2.get_layout_height()); } #[test] fn test_justify_content_min_width_with_padding_child_width_greater_than_parent() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_width(StyleUnit::Point((1000 as f32).into())); root.set_height(StyleUnit::Point((1584 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_flex_direction(FlexDirection::Row); root_child0.set_align_content(Align::Stretch); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child0_child0 = Node::new_with_config(&mut config); root_child0_child0.set_flex_direction(FlexDirection::Row); root_child0_child0.set_justify_content(Justify::Center); root_child0_child0.set_align_content(Align::Stretch); root_child0_child0.set_padding(Edge::Left, StyleUnit::Point((100 as f32).into())); root_child0_child0.set_padding(Edge::Right, StyleUnit::Point((100 as f32).into())); root_child0_child0.set_min_width(StyleUnit::Point((400 as f32).into())); root_child0_child0.set_min_height(StyleUnit::Auto); root_child0.insert_child(&mut root_child0_child0, 0); let mut root_child0_child0_child0 = Node::new_with_config(&mut config); root_child0_child0_child0.set_flex_direction(FlexDirection::Row); root_child0_child0_child0.set_align_content(Align::Stretch); root_child0_child0_child0.set_width(StyleUnit::Point((300 as f32).into())); root_child0_child0_child0.set_min_width(StyleUnit::Auto); root_child0_child0_child0.set_height(StyleUnit::Point((100 as f32).into())); root_child0_child0_child0.set_min_height(StyleUnit::Auto); root_child0_child0.insert_child(&mut root_child0_child0_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(1000 as f32, root.get_layout_width()); assert_eq!(1584 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(1000 as f32, root_child0.get_layout_width()); assert_eq!(100 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0.get_layout_top()); assert_eq!(500 as f32, root_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0.get_layout_height()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0_child0.get_layout_top()); assert_eq!(300 as f32, root_child0_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(1000 as f32, root.get_layout_width()); assert_eq!(1584 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(1000 as f32, root_child0.get_layout_width()); assert_eq!(100 as f32, root_child0.get_layout_height()); assert_eq!(500 as f32, root_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0.get_layout_top()); assert_eq!(500 as f32, root_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0.get_layout_height()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0_child0.get_layout_top()); assert_eq!(300 as f32, root_child0_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_height()); } #[test] fn test_justify_content_min_width_with_padding_child_width_greater_than_parent_1() { let mut config = Config::new(); let mut root = Node::new_with_config(&mut config); root.set_width(StyleUnit::Point((1080 as f32).into())); root.set_height(StyleUnit::Point((1584 as f32).into())); let mut root_child0 = Node::new_with_config(&mut config); root_child0.set_flex_direction(FlexDirection::Row); root_child0.set_align_content(Align::Stretch); root_child0.set_min_width(StyleUnit::Auto); root_child0.set_min_height(StyleUnit::Auto); root.insert_child(&mut root_child0, 0); let mut root_child0_child0 = Node::new_with_config(&mut config); root_child0_child0.set_flex_direction(FlexDirection::Row); root_child0_child0.set_justify_content(Justify::Center); root_child0_child0.set_align_content(Align::Stretch); root_child0_child0.set_padding(Edge::Left, StyleUnit::Point((100 as f32).into())); root_child0_child0.set_padding(Edge::Right, StyleUnit::Point((100 as f32).into())); root_child0_child0.set_min_width(StyleUnit::Point((400 as f32).into())); root_child0_child0.set_min_height(StyleUnit::Auto); root_child0.insert_child(&mut root_child0_child0, 0); let mut root_child0_child0_child0 = Node::new_with_config(&mut config); root_child0_child0_child0.set_flex_direction(FlexDirection::Row); root_child0_child0_child0.set_align_content(Align::Stretch); root_child0_child0_child0.set_width(StyleUnit::Point((199 as f32).into())); root_child0_child0_child0.set_min_width(StyleUnit::Auto); root_child0_child0_child0.set_height(StyleUnit::Point((100 as f32).into())); root_child0_child0_child0.set_min_height(StyleUnit::Auto); root_child0_child0.insert_child(&mut root_child0_child0_child0, 0); root.calculate_layout(Undefined, Undefined, Direction::LTR); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(1080 as f32, root.get_layout_width()); assert_eq!(1584 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(1080 as f32, root_child0.get_layout_width()); assert_eq!(100 as f32, root_child0.get_layout_height()); assert_eq!(0 as f32, root_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0.get_layout_top()); assert_eq!(400 as f32, root_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0.get_layout_height()); assert_eq!(101 as f32, root_child0_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0_child0.get_layout_top()); assert_eq!(199 as f32, root_child0_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_height()); root.calculate_layout(Undefined, Undefined, Direction::RTL); assert_eq!(0 as f32, root.get_layout_left()); assert_eq!(0 as f32, root.get_layout_top()); assert_eq!(1080 as f32, root.get_layout_width()); assert_eq!(1584 as f32, root.get_layout_height()); assert_eq!(0 as f32, root_child0.get_layout_left()); assert_eq!(0 as f32, root_child0.get_layout_top()); assert_eq!(1080 as f32, root_child0.get_layout_width()); assert_eq!(100 as f32, root_child0.get_layout_height()); assert_eq!(680 as f32, root_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0.get_layout_top()); assert_eq!(400 as f32, root_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0.get_layout_height()); assert_eq!(101 as f32, root_child0_child0_child0.get_layout_left()); assert_eq!(0 as f32, root_child0_child0_child0.get_layout_top()); assert_eq!(199 as f32, root_child0_child0_child0.get_layout_width()); assert_eq!(100 as f32, root_child0_child0_child0.get_layout_height()); }