[gentest] Split generated tests into separate files.
Delta semántico · 238
tests/generated/absolute_layout_align_items_and_justify_content_center.rs
tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs
tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs
tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs
tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs
tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs
tests/generated/absolute_layout_align_items_center.rs
- nueva fn absolute_layout_align_items_center
tests/generated/absolute_layout_align_items_center_on_child_only.rs
tests/generated/absolute_layout_child_order.rs
- nueva fn absolute_layout_child_order
tests/generated/absolute_layout_in_wrap_reverse_column_container.rs
tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs
tests/generated/absolute_layout_in_wrap_reverse_row_container.rs
tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs
tests/generated/absolute_layout_justify_content_center.rs
tests/generated/absolute_layout_no_size.rs
- nueva fn absolute_layout_no_size
tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs
tests/generated/absolute_layout_start_top_end_bottom.rs
- nueva fn absolute_layout_start_top_end_bottom
tests/generated/absolute_layout_width_height_end_bottom.rs
tests/generated/absolute_layout_width_height_start_top.rs
tests/generated/absolute_layout_width_height_start_top_end_bottom.rs
tests/generated/absolute_layout_within_border.rs
- nueva fn absolute_layout_within_border
tests/generated/align_baseline.rs
- nueva fn align_baseline
tests/generated/align_baseline_child_multiline.rs
- nueva fn align_baseline_child_multiline
tests/generated/align_baseline_nested_child.rs
- nueva fn align_baseline_nested_child
tests/generated/align_center_should_size_based_on_content.rs
tests/generated/align_flex_start_with_shrinking_children.rs
tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs
tests/generated/align_flex_start_with_stretching_children.rs
tests/generated/align_items_center.rs
- nueva fn align_items_center
tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs
tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs
tests/generated/align_items_center_with_child_margin.rs
- nueva fn align_items_center_with_child_margin
tests/generated/align_items_center_with_child_top.rs
- nueva fn align_items_center_with_child_top
tests/generated/align_items_flex_end.rs
- nueva fn align_items_flex_end
tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs
tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs
tests/generated/align_items_flex_start.rs
- nueva fn align_items_flex_start
tests/generated/align_items_min_max.rs
- nueva fn align_items_min_max
tests/generated/align_items_stretch.rs
- nueva fn align_items_stretch
tests/generated/align_self_baseline.rs
- nueva fn align_self_baseline
tests/generated/align_self_center.rs
- nueva fn align_self_center
tests/generated/align_self_flex_end.rs
- nueva fn align_self_flex_end
tests/generated/align_self_flex_end_override_flex_start.rs
tests/generated/align_self_flex_start.rs
- nueva fn align_self_flex_start
tests/generated/align_strech_should_size_based_on_parent.rs
tests/generated/border_center_child.rs
- nueva fn border_center_child
tests/generated/border_flex_child.rs
- nueva fn border_flex_child
tests/generated/border_no_child.rs
- nueva fn border_no_child
tests/generated/border_stretch_child.rs
- nueva fn border_stretch_child
tests/generated/child_min_max_width_flexing.rs
- nueva fn child_min_max_width_flexing
tests/generated/container_with_unsized_child.rs
- nueva fn container_with_unsized_child
tests/generated/display_none.rs
- nueva fn display_none
tests/generated/display_none_fixed_size.rs
- nueva fn display_none_fixed_size
tests/generated/display_none_with_child.rs
- nueva fn display_none_with_child
tests/generated/display_none_with_margin.rs
- nueva fn display_none_with_margin
tests/generated/display_none_with_position.rs
- nueva fn display_none_with_position
tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs
tests/generated/flex_basis_flex_grow_column.rs
- nueva fn flex_basis_flex_grow_column
tests/generated/flex_basis_flex_grow_row.rs
- nueva fn flex_basis_flex_grow_row
tests/generated/flex_basis_flex_shrink_column.rs
- nueva fn flex_basis_flex_shrink_column
tests/generated/flex_basis_flex_shrink_row.rs
- nueva fn flex_basis_flex_shrink_row
tests/generated/flex_basis_larger_than_content_column.rs
tests/generated/flex_basis_larger_than_content_row.rs
- nueva fn flex_basis_larger_than_content_row
tests/generated/flex_basis_overrides_main_size.rs
- nueva fn flex_basis_overrides_main_size
tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs
tests/generated/flex_basis_smaller_than_content_column.rs
tests/generated/flex_basis_smaller_than_content_row.rs
- nueva fn flex_basis_smaller_than_content_row
tests/generated/flex_basis_smaller_than_main_dimen_column.rs
tests/generated/flex_basis_smaller_than_main_dimen_row.rs
tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs
tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs
tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs
tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs
tests/generated/flex_basis_unconstraint_column.rs
- nueva fn flex_basis_unconstraint_column
tests/generated/flex_basis_unconstraint_row.rs
- nueva fn flex_basis_unconstraint_row
tests/generated/flex_direction_column.rs
- nueva fn flex_direction_column
tests/generated/flex_direction_column_no_height.rs
- nueva fn flex_direction_column_no_height
tests/generated/flex_direction_column_reverse.rs
- nueva fn flex_direction_column_reverse
tests/generated/flex_direction_row.rs
- nueva fn flex_direction_row
tests/generated/flex_direction_row_no_width.rs
- nueva fn flex_direction_row_no_width
tests/generated/flex_direction_row_reverse.rs
- nueva fn flex_direction_row_reverse
tests/generated/flex_grow_child.rs
- nueva fn flex_grow_child
tests/generated/flex_grow_flex_basis_percent_min_max.rs
- nueva fn flex_grow_flex_basis_percent_min_max
tests/generated/flex_grow_height_maximized.rs
- nueva fn flex_grow_height_maximized
tests/generated/flex_grow_in_at_most_container.rs
- nueva fn flex_grow_in_at_most_container
tests/generated/flex_grow_less_than_factor_one.rs
- nueva fn flex_grow_less_than_factor_one
tests/generated/flex_grow_root_minimized.rs
- nueva fn flex_grow_root_minimized
tests/generated/flex_grow_shrink_at_most.rs
- nueva fn flex_grow_shrink_at_most
tests/generated/flex_grow_to_min.rs
- nueva fn flex_grow_to_min
tests/generated/flex_grow_within_constrained_max_column.rs
tests/generated/flex_grow_within_constrained_max_row.rs
- nueva fn flex_grow_within_constrained_max_row
tests/generated/flex_grow_within_constrained_max_width.rs
tests/generated/flex_grow_within_constrained_min_column.rs
tests/generated/flex_grow_within_constrained_min_max_column.rs
tests/generated/flex_grow_within_constrained_min_row.rs
- nueva fn flex_grow_within_constrained_min_row
tests/generated/flex_grow_within_max_width.rs
- nueva fn flex_grow_within_max_width
tests/generated/flex_root_ignored.rs
- nueva fn flex_root_ignored
tests/generated/flex_shrink_by_outer_margin_with_max_size.rs
tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs
tests/generated/flex_shrink_flex_grow_row.rs
- nueva fn flex_shrink_flex_grow_row
tests/generated/flex_shrink_to_zero.rs
- nueva fn flex_shrink_to_zero
tests/generated/flex_wrap_align_stretch_fits_one_row.rs
- nueva fn flex_wrap_align_stretch_fits_one_row
tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs
tests/generated/flex_wrap_wrap_to_child_height.rs
- nueva fn flex_wrap_wrap_to_child_height
tests/generated/justify_content_column_center.rs
- nueva fn justify_content_column_center
tests/generated/justify_content_column_flex_end.rs
- nueva fn justify_content_column_flex_end
tests/generated/justify_content_column_flex_start.rs
- nueva fn justify_content_column_flex_start
tests/generated/justify_content_column_min_height_and_margin_bottom.rs
tests/generated/justify_content_column_min_height_and_margin_top.rs
tests/generated/justify_content_column_space_around.rs
- nueva fn justify_content_column_space_around
tests/generated/justify_content_column_space_between.rs
- nueva fn justify_content_column_space_between
tests/generated/justify_content_column_space_evenly.rs
- nueva fn justify_content_column_space_evenly
tests/generated/justify_content_min_max.rs
- nueva fn justify_content_min_max
tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs
tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs
tests/generated/justify_content_overflow_min_max.rs
- nueva fn justify_content_overflow_min_max
tests/generated/justify_content_row_center.rs
- nueva fn justify_content_row_center
tests/generated/justify_content_row_flex_end.rs
- nueva fn justify_content_row_flex_end
tests/generated/justify_content_row_flex_start.rs
- nueva fn justify_content_row_flex_start
tests/generated/justify_content_row_max_width_and_margin.rs
tests/generated/justify_content_row_min_width_and_margin.rs
tests/generated/justify_content_row_space_around.rs
- nueva fn justify_content_row_space_around
tests/generated/justify_content_row_space_between.rs
- nueva fn justify_content_row_space_between
tests/generated/justify_content_row_space_evenly.rs
- nueva fn justify_content_row_space_evenly
tests/generated/margin_and_flex_column.rs
- nueva fn margin_and_flex_column
tests/generated/margin_and_flex_row.rs
- nueva fn margin_and_flex_row
tests/generated/margin_and_stretch_column.rs
- nueva fn margin_and_stretch_column
tests/generated/margin_and_stretch_row.rs
- nueva fn margin_and_stretch_row
tests/generated/margin_auto_bottom.rs
- nueva fn margin_auto_bottom
tests/generated/margin_auto_bottom_and_top.rs
- nueva fn margin_auto_bottom_and_top
tests/generated/margin_auto_bottom_and_top_justify_center.rs
tests/generated/margin_auto_left.rs
- nueva fn margin_auto_left
tests/generated/margin_auto_left_and_right.rs
- nueva fn margin_auto_left_and_right
tests/generated/margin_auto_left_and_right_column.rs
- nueva fn margin_auto_left_and_right_column
tests/generated/margin_auto_left_and_right_column_and_center.rs
tests/generated/margin_auto_left_and_right_strech.rs
- nueva fn margin_auto_left_and_right_strech
tests/generated/margin_auto_left_child_bigger_than_parent.rs
tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs
tests/generated/margin_auto_left_right_child_bigger_than_parent.rs
tests/generated/margin_auto_left_stretching_child.rs
- nueva fn margin_auto_left_stretching_child
tests/generated/margin_auto_mutiple_children_column.rs
- nueva fn margin_auto_mutiple_children_column
tests/generated/margin_auto_mutiple_children_row.rs
- nueva fn margin_auto_mutiple_children_row
tests/generated/margin_auto_right.rs
- nueva fn margin_auto_right
tests/generated/margin_auto_top.rs
- nueva fn margin_auto_top
tests/generated/margin_auto_top_and_bottom_strech.rs
- nueva fn margin_auto_top_and_bottom_strech
tests/generated/margin_auto_top_stretching_child.rs
- nueva fn margin_auto_top_stretching_child
tests/generated/margin_bottom.rs
- nueva fn margin_bottom
tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs
tests/generated/margin_left.rs
- nueva fn margin_left
tests/generated/margin_right.rs
- nueva fn margin_right
tests/generated/margin_should_not_be_part_of_max_height.rs
tests/generated/margin_should_not_be_part_of_max_width.rs
tests/generated/margin_top.rs
- nueva fn margin_top
tests/generated/margin_with_sibling_column.rs
- nueva fn margin_with_sibling_column
tests/generated/margin_with_sibling_row.rs
- nueva fn margin_with_sibling_row
tests/generated/max_height.rs
- nueva fn max_height
tests/generated/max_height_overrides_height.rs
- nueva fn max_height_overrides_height
tests/generated/max_height_overrides_height_on_root.rs
- nueva fn max_height_overrides_height_on_root
tests/generated/max_width.rs
- nueva fn max_width
tests/generated/max_width_overrides_width.rs
- nueva fn max_width_overrides_width
tests/generated/max_width_overrides_width_on_root.rs
- nueva fn max_width_overrides_width_on_root
tests/generated/min_height.rs
- nueva fn min_height
tests/generated/min_height_overrides_height.rs
- nueva fn min_height_overrides_height
tests/generated/min_height_overrides_height_on_root.rs
- nueva fn min_height_overrides_height_on_root
tests/generated/min_max_percent_no_width_height.rs
- nueva fn min_max_percent_no_width_height
tests/generated/min_width.rs
- nueva fn min_width
tests/generated/min_width_overrides_width.rs
- nueva fn min_width_overrides_width
tests/generated/min_width_overrides_width_on_root.rs
- nueva fn min_width_overrides_width_on_root
tests/generated/nested_overflowing_child.rs
- nueva fn nested_overflowing_child
tests/generated/nested_overflowing_child_in_constraint_parent.rs
tests/generated/overflow_cross_axis.rs
- nueva fn overflow_cross_axis
tests/generated/overflow_main_axis.rs
- nueva fn overflow_main_axis
tests/generated/padding_align_end_child.rs
- nueva fn padding_align_end_child
tests/generated/padding_center_child.rs
- nueva fn padding_center_child
tests/generated/padding_flex_child.rs
- nueva fn padding_flex_child
tests/generated/padding_no_child.rs
- nueva fn padding_no_child
tests/generated/padding_stretch_child.rs
- nueva fn padding_stretch_child
tests/generated/parent_wrap_child_size_overflowing_parent.rs
tests/generated/percent_absolute_position.rs
- nueva fn percent_absolute_position
tests/generated/percent_within_flex_grow.rs
- nueva fn percent_within_flex_grow
tests/generated/percentage_absolute_position.rs
- nueva fn percentage_absolute_position
tests/generated/percentage_container_in_wrapping_container.rs
tests/generated/percentage_flex_basis.rs
- nueva fn percentage_flex_basis
tests/generated/percentage_flex_basis_cross.rs
- nueva fn percentage_flex_basis_cross
tests/generated/percentage_flex_basis_cross_max_height.rs
tests/generated/percentage_flex_basis_cross_max_width.rs
tests/generated/percentage_flex_basis_cross_min_height.rs
tests/generated/percentage_flex_basis_cross_min_width.rs
tests/generated/percentage_flex_basis_main_max_height.rs
tests/generated/percentage_flex_basis_main_max_width.rs
- nueva fn percentage_flex_basis_main_max_width
tests/generated/percentage_flex_basis_main_min_width.rs
- nueva fn percentage_flex_basis_main_min_width
tests/generated/percentage_margin_should_calculate_based_only_on_width.rs
tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs
tests/generated/percentage_padding_should_calculate_based_only_on_width.rs
tests/generated/percentage_position_bottom_right.rs
- nueva fn percentage_position_bottom_right
tests/generated/percentage_position_left_top.rs
- nueva fn percentage_position_left_top
tests/generated/percentage_size_based_on_parent_inner_size.rs
tests/generated/percentage_size_of_flex_basis.rs
- nueva fn percentage_size_of_flex_basis
tests/generated/percentage_width_height.rs
- nueva fn percentage_width_height
tests/generated/percentage_width_height_undefined_parent_size.rs
tests/generated/relative_position_should_not_nudge_siblings.rs
tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs
tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs
tests/generated/rounding_flex_basis_flex_shrink_row.rs
- nueva fn rounding_flex_basis_flex_shrink_row
tests/generated/rounding_flex_basis_overrides_main_size.rs
tests/generated/rounding_fractial_input_1.rs
- nueva fn rounding_fractial_input_1
tests/generated/rounding_fractial_input_2.rs
- nueva fn rounding_fractial_input_2
tests/generated/rounding_fractial_input_3.rs
- nueva fn rounding_fractial_input_3
tests/generated/rounding_fractial_input_4.rs
- nueva fn rounding_fractial_input_4
tests/generated/rounding_total_fractial.rs
- nueva fn rounding_total_fractial
tests/generated/rounding_total_fractial_nested.rs
- nueva fn rounding_total_fractial_nested
tests/generated/size_defined_by_child.rs
- nueva fn size_defined_by_child
tests/generated/size_defined_by_child_with_border.rs
- nueva fn size_defined_by_child_with_border
tests/generated/size_defined_by_child_with_padding.rs
- nueva fn size_defined_by_child_with_padding
tests/generated/size_defined_by_grand_child.rs
- nueva fn size_defined_by_grand_child
tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs
tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs
tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs
tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs
tests/generated/wrap_column.rs
- nueva fn wrap_column
tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs
tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs
tests/generated/wrap_reverse_column.rs
- nueva fn wrap_reverse_column
tests/generated/wrap_reverse_column_fixed_size.rs
- nueva fn wrap_reverse_column_fixed_size
tests/generated/wrap_reverse_row.rs
- nueva fn wrap_reverse_row
tests/generated/wrap_reverse_row_align_content_center.rs
tests/generated/wrap_reverse_row_align_content_flex_start.rs
tests/generated/wrap_reverse_row_align_content_space_around.rs
tests/generated/wrap_reverse_row_align_content_stretch.rs
tests/generated/wrap_reverse_row_single_line_different_size.rs
tests/generated/wrap_row.rs
- nueva fn wrap_row
tests/generated/wrap_row_align_items_center.rs
- nueva fn wrap_row_align_items_center
tests/generated/wrap_row_align_items_flex_end.rs
- nueva fn wrap_row_align_items_flex_end
tests/generated/wrapped_column_max_height.rs
- nueva fn wrapped_column_max_height
tests/generated/wrapped_column_max_height_flex.rs
- nueva fn wrapped_column_max_height_flex
tests/generated/wrapped_row_within_align_items_center.rs
tests/generated/wrapped_row_within_align_items_flex_end.rs
tests/generated/wrapped_row_within_align_items_flex_start.rs
239 archivos · +11995 −12159
- tests/generated.rs +238 −12159
- tests/generated/absolute_layout_align_items_and_justify_content_center.rs +36 −0
- tests/generated/absolute_layout_align_items_and_justify_content_center_and_bottom_position.rs +40 −0
- tests/generated/absolute_layout_align_items_and_justify_content_center_and_left_position.rs +40 −0
- tests/generated/absolute_layout_align_items_and_justify_content_center_and_right_position.rs +40 −0
- tests/generated/absolute_layout_align_items_and_justify_content_center_and_top_position.rs +40 −0
- tests/generated/absolute_layout_align_items_and_justify_content_flex_end.rs +36 −0
- tests/generated/absolute_layout_align_items_center.rs +35 −0
- tests/generated/absolute_layout_align_items_center_on_child_only.rs +35 −0
- tests/generated/absolute_layout_child_order.rs +64 −0
- tests/generated/absolute_layout_in_wrap_reverse_column_container.rs +36 −0
- tests/generated/absolute_layout_in_wrap_reverse_column_container_flex_end.rs +37 −0
- tests/generated/absolute_layout_in_wrap_reverse_row_container.rs +35 −0
- tests/generated/absolute_layout_in_wrap_reverse_row_container_flex_end.rs +36 −0
- tests/generated/absolute_layout_justify_content_center.rs +35 −0
- tests/generated/absolute_layout_no_size.rs +29 −0
- tests/generated/absolute_layout_percentage_bottom_based_on_parent_height.rs +76 −0
- tests/generated/absolute_layout_start_top_end_bottom.rs +36 −0
- tests/generated/absolute_layout_width_height_end_bottom.rs +39 −0
- tests/generated/absolute_layout_width_height_start_top.rs +39 −0
- tests/generated/absolute_layout_width_height_start_top_end_bottom.rs +41 −0
- tests/generated/absolute_layout_within_border.rs +126 −0
- tests/generated/align_baseline.rs +49 −0
- tests/generated/align_baseline_child_multiline.rs +99 −0
- tests/generated/align_baseline_nested_child.rs +63 −0
- tests/generated/align_center_should_size_based_on_content.rs +55 −0
- tests/generated/align_flex_start_with_shrinking_children.rs +49 −0
- tests/generated/align_flex_start_with_shrinking_children_with_stretch.rs +49 −0
- tests/generated/align_flex_start_with_stretching_children.rs +48 −0
- tests/generated/align_items_center.rs +34 −0
- tests/generated/align_items_center_child_with_margin_bigger_than_parent.rs +49 −0
- tests/generated/align_items_center_child_without_margin_bigger_than_parent.rs +44 −0
- tests/generated/align_items_center_with_child_margin.rs +38 −0
- tests/generated/align_items_center_with_child_top.rs +38 −0
- tests/generated/align_items_flex_end.rs +34 −0
- tests/generated/align_items_flex_end_child_with_margin_bigger_than_parent.rs +49 −0
- tests/generated/align_items_flex_end_child_without_margin_bigger_than_parent.rs +44 −0
- tests/generated/align_items_flex_start.rs +34 −0
- tests/generated/align_items_min_max.rs +39 −0
- tests/generated/align_items_stretch.rs +32 −0
- tests/generated/align_self_baseline.rs +63 −0
- tests/generated/align_self_center.rs +34 −0
- tests/generated/align_self_flex_end.rs +34 −0
- tests/generated/align_self_flex_end_override_flex_start.rs +35 −0
- tests/generated/align_self_flex_start.rs +34 −0
- tests/generated/align_strech_should_size_based_on_parent.rs +54 −0
- tests/generated/border_center_child.rs +40 −0
- tests/generated/border_flex_child.rs +40 −0
- tests/generated/border_no_child.rs +22 −0
- tests/generated/border_stretch_child.rs +39 −0
- tests/generated/child_min_max_width_flexing.rs +52 −0
- tests/generated/container_with_unsized_child.rs +26 −0
- tests/generated/display_none.rs +38 −0
- tests/generated/display_none_fixed_size.rs +42 −0
- tests/generated/display_none_with_child.rs +72 −0
- tests/generated/display_none_with_margin.rs +49 −0
- tests/generated/display_none_with_position.rs +42 −0
- tests/generated/flex_basis_and_main_dimen_set_when_flexing.rs +48 −0
- tests/generated/flex_basis_flex_grow_column.rs +39 −0
- tests/generated/flex_basis_flex_grow_row.rs +38 −0
- tests/generated/flex_basis_flex_shrink_column.rs +35 −0
- tests/generated/flex_basis_flex_shrink_row.rs +34 −0
- tests/generated/flex_basis_larger_than_content_column.rs +40 −0
- tests/generated/flex_basis_larger_than_content_row.rs +39 −0
- tests/generated/flex_basis_overrides_main_size.rs +62 −0
- tests/generated/flex_basis_slightly_smaller_then_content_with_flex_grow_large_size.rs +66 −0
- tests/generated/flex_basis_smaller_than_content_column.rs +40 −0
- tests/generated/flex_basis_smaller_than_content_row.rs +39 −0
- tests/generated/flex_basis_smaller_than_main_dimen_column.rs +31 −0
- tests/generated/flex_basis_smaller_than_main_dimen_row.rs +30 −0
- tests/generated/flex_basis_smaller_then_content_with_flex_grow_large_size.rs +66 −0
- tests/generated/flex_basis_smaller_then_content_with_flex_grow_small_size.rs +66 −0
- tests/generated/flex_basis_smaller_then_content_with_flex_grow_unconstraint_size.rs +65 −0
- tests/generated/flex_basis_smaller_then_content_with_flex_grow_very_large_size.rs +66 −0
- tests/generated/flex_basis_unconstraint_column.rs +29 −0
- tests/generated/flex_basis_unconstraint_row.rs +28 −0
- tests/generated/flex_direction_column.rs +59 −0
- tests/generated/flex_direction_column_no_height.rs +55 −0
- tests/generated/flex_direction_column_reverse.rs +59 −0
- tests/generated/flex_direction_row.rs +58 −0
- tests/generated/flex_direction_row_no_width.rs +54 −0
- tests/generated/flex_direction_row_reverse.rs +59 −0
- tests/generated/flex_grow_child.rs +29 −0
- tests/generated/flex_grow_flex_basis_percent_min_max.rs +57 −0
- tests/generated/flex_grow_height_maximized.rs +63 −0
- tests/generated/flex_grow_in_at_most_container.rs +39 −0
- tests/generated/flex_grow_less_than_factor_one.rs +45 −0
- tests/generated/flex_grow_root_minimized.rs +67 −0
- tests/generated/flex_grow_shrink_at_most.rs +34 −0
- tests/generated/flex_grow_to_min.rs +45 −0
- tests/generated/flex_grow_within_constrained_max_column.rs +45 −0
- tests/generated/flex_grow_within_constrained_max_row.rs +57 −0
- tests/generated/flex_grow_within_constrained_max_width.rs +46 −0
- tests/generated/flex_grow_within_constrained_min_column.rs +40 −0
- tests/generated/flex_grow_within_constrained_min_max_column.rs +39 −0
- tests/generated/flex_grow_within_constrained_min_row.rs +40 −0
- tests/generated/flex_grow_within_max_width.rs +46 −0
- tests/generated/flex_root_ignored.rs +49 −0
- tests/generated/flex_shrink_by_outer_margin_with_max_size.rs +38 −0
- tests/generated/flex_shrink_flex_grow_child_flex_shrink_other_child.rs +52 −0
- tests/generated/flex_shrink_flex_grow_row.rs +52 −0
- tests/generated/flex_shrink_to_zero.rs +60 −0
- tests/generated/flex_wrap_align_stretch_fits_one_row.rs +47 −0
- tests/generated/flex_wrap_children_with_min_main_overriding_flex_basis.rs +53 −0
- tests/generated/flex_wrap_wrap_to_child_height.rs +67 −0
- tests/generated/justify_content_column_center.rs +60 −0
- tests/generated/justify_content_column_flex_end.rs +60 −0
- tests/generated/justify_content_column_flex_start.rs +59 −0
- tests/generated/justify_content_column_min_height_and_margin_bottom.rs +38 −0
- tests/generated/justify_content_column_min_height_and_margin_top.rs +38 −0
- tests/generated/justify_content_column_space_around.rs +60 −0
- tests/generated/justify_content_column_space_between.rs +60 −0
- tests/generated/justify_content_column_space_evenly.rs +60 −0
- tests/generated/justify_content_min_max.rs +39 −0
- tests/generated/justify_content_min_width_with_padding_child_width_greater_than_parent.rs +60 −0
- tests/generated/justify_content_min_width_with_padding_child_width_lower_than_parent.rs +60 −0
- tests/generated/justify_content_overflow_min_max.rs +69 −0
- tests/generated/justify_content_row_center.rs +59 −0
- tests/generated/justify_content_row_flex_end.rs +59 −0
- tests/generated/justify_content_row_flex_start.rs +58 −0
- tests/generated/justify_content_row_max_width_and_margin.rs +38 −0
- tests/generated/justify_content_row_min_width_and_margin.rs +37 −0
- tests/generated/justify_content_row_space_around.rs +59 −0
- tests/generated/justify_content_row_space_between.rs +59 −0
- tests/generated/justify_content_row_space_evenly.rs +59 −0
- tests/generated/margin_and_flex_column.rs +35 −0
- tests/generated/margin_and_flex_row.rs +34 −0
- tests/generated/margin_and_stretch_column.rs +35 −0
- tests/generated/margin_and_stretch_row.rs +34 −0
- tests/generated/margin_auto_bottom.rs +50 −0
- tests/generated/margin_auto_bottom_and_top.rs +54 −0
- tests/generated/margin_auto_bottom_and_top_justify_center.rs +54 −0
- tests/generated/margin_auto_left.rs +50 −0
- tests/generated/margin_auto_left_and_right.rs +53 −0
- tests/generated/margin_auto_left_and_right_column.rs +54 −0
- tests/generated/margin_auto_left_and_right_column_and_center.rs +54 −0
- tests/generated/margin_auto_left_and_right_strech.rs +53 −0
- tests/generated/margin_auto_left_child_bigger_than_parent.rs +35 −0
- tests/generated/margin_auto_left_fix_right_child_bigger_than_parent.rs +39 −0
- tests/generated/margin_auto_left_right_child_bigger_than_parent.rs +39 −0
- tests/generated/margin_auto_left_stretching_child.rs +48 −0
- tests/generated/margin_auto_mutiple_children_column.rs +65 −0
- tests/generated/margin_auto_mutiple_children_row.rs +64 −0
- tests/generated/margin_auto_right.rs +50 −0
- tests/generated/margin_auto_top.rs +50 −0
- tests/generated/margin_auto_top_and_bottom_strech.rs +54 −0
- tests/generated/margin_auto_top_stretching_child.rs +48 −0
- tests/generated/margin_bottom.rs +38 −0
- tests/generated/margin_fix_left_auto_right_child_bigger_than_parent.rs +39 −0
- tests/generated/margin_left.rs +36 −0
- tests/generated/margin_right.rs +37 −0
- tests/generated/margin_should_not_be_part_of_max_height.rs +41 −0
- tests/generated/margin_should_not_be_part_of_max_width.rs +41 −0
- tests/generated/margin_top.rs +37 −0
- tests/generated/margin_with_sibling_column.rs +42 −0
- tests/generated/margin_with_sibling_row.rs +41 −0
- tests/generated/max_height.rs +36 −0
- tests/generated/max_height_overrides_height.rs +31 −0
- tests/generated/max_height_overrides_height_on_root.rs +20 −0
- tests/generated/max_width.rs +37 −0
- tests/generated/max_width_overrides_width.rs +31 −0
- tests/generated/max_width_overrides_width_on_root.rs +20 −0
- tests/generated/min_height.rs +42 −0
- tests/generated/min_height_overrides_height.rs +31 −0
- tests/generated/min_height_overrides_height_on_root.rs +20 −0
- tests/generated/min_max_percent_no_width_height.rs +40 −0
- tests/generated/min_width.rs +41 −0
- tests/generated/min_width_overrides_width.rs +31 −0
- tests/generated/min_width_overrides_width_on_root.rs +20 −0
- tests/generated/nested_overflowing_child.rs +41 −0
- tests/generated/nested_overflowing_child_in_constraint_parent.rs +46 −0
- tests/generated/overflow_cross_axis.rs +33 −0
- tests/generated/overflow_main_axis.rs +33 −0
- tests/generated/padding_align_end_child.rs +42 −0
- tests/generated/padding_center_child.rs +42 −0
- tests/generated/padding_flex_child.rs +40 −0
- tests/generated/padding_no_child.rs +22 −0
- tests/generated/padding_stretch_child.rs +39 −0
- tests/generated/parent_wrap_child_size_overflowing_parent.rs +45 −0
- tests/generated/percent_absolute_position.rs +65 −0
- tests/generated/percent_within_flex_grow.rs +68 −0
- tests/generated/percentage_absolute_position.rs +40 −0
- tests/generated/percentage_container_in_wrapping_container.rs +73 −0
- tests/generated/percentage_flex_basis.rs +42 −0
- tests/generated/percentage_flex_basis_cross.rs +43 −0
- tests/generated/percentage_flex_basis_cross_max_height.rs +51 −0
- tests/generated/percentage_flex_basis_cross_max_width.rs +51 −0
- tests/generated/percentage_flex_basis_cross_min_height.rs +49 −0
- tests/generated/percentage_flex_basis_cross_min_width.rs +51 −0
- tests/generated/percentage_flex_basis_main_max_height.rs +50 −0
- tests/generated/percentage_flex_basis_main_max_width.rs +50 −0
- tests/generated/percentage_flex_basis_main_min_width.rs +50 −0
- tests/generated/percentage_margin_should_calculate_based_only_on_width.rs +51 −0
- tests/generated/percentage_multiple_nested_with_padding_margin_and_percentage_values.rs +119 −0
- tests/generated/percentage_padding_should_calculate_based_only_on_width.rs +51 −0
- tests/generated/percentage_position_bottom_right.rs +38 −0
- tests/generated/percentage_position_left_top.rs +38 −0
- tests/generated/percentage_size_based_on_parent_inner_size.rs +41 −0
- tests/generated/percentage_size_of_flex_basis.rs +38 −0
- tests/generated/percentage_width_height.rs +33 −0
- tests/generated/percentage_width_height_undefined_parent_size.rs +29 −0
- tests/generated/relative_position_should_not_nudge_siblings.rs +55 −0
- tests/generated/rounding_flex_basis_flex_grow_row_prime_number_width.rs +52 −0
- tests/generated/rounding_flex_basis_flex_grow_row_width_of_100.rs +40 −0
- tests/generated/rounding_flex_basis_flex_shrink_row.rs +44 −0
- tests/generated/rounding_flex_basis_overrides_main_size.rs +63 −0
- tests/generated/rounding_fractial_input_1.rs +63 −0
- tests/generated/rounding_fractial_input_2.rs +63 −0
- tests/generated/rounding_fractial_input_3.rs +63 −0
- tests/generated/rounding_fractial_input_4.rs +63 −0
- tests/generated/rounding_total_fractial.rs +63 −0
- tests/generated/rounding_total_fractial_nested.rs +102 −0
- tests/generated/size_defined_by_child.rs +28 −0
- tests/generated/size_defined_by_child_with_border.rs +35 −0
- tests/generated/size_defined_by_child_with_padding.rs +35 −0
- tests/generated/size_defined_by_grand_child.rs +36 −0
- tests/generated/width_smaller_then_content_with_flex_grow_large_size.rs +72 −0
- tests/generated/width_smaller_then_content_with_flex_grow_small_size.rs +72 −0
- tests/generated/width_smaller_then_content_with_flex_grow_unconstraint_size.rs +71 −0
- tests/generated/width_smaller_then_content_with_flex_grow_very_large_size.rs +72 −0
- tests/generated/wrap_column.rs +76 −0
- tests/generated/wrap_nodes_with_content_sizing_margin_cross.rs +84 −0
- tests/generated/wrap_nodes_with_content_sizing_overflowing_margin.rs +84 −0
- tests/generated/wrap_reverse_column.rs +76 −0
- tests/generated/wrap_reverse_column_fixed_size.rs +90 −0
- tests/generated/wrap_reverse_row.rs +71 −0
- tests/generated/wrap_reverse_row_align_content_center.rs +85 −0
- tests/generated/wrap_reverse_row_align_content_flex_start.rs +85 −0
- tests/generated/wrap_reverse_row_align_content_space_around.rs +85 −0
- tests/generated/wrap_reverse_row_align_content_stretch.rs +84 −0
- tests/generated/wrap_reverse_row_single_line_different_size.rs +85 −0
- tests/generated/wrap_row.rs +71 −0
- tests/generated/wrap_row_align_items_center.rs +72 −0
- tests/generated/wrap_row_align_items_flex_end.rs +72 −0
- tests/generated/wrapped_column_max_height.rs +77 −0
- tests/generated/wrapped_column_max_height_flex.rs +83 −0
- tests/generated/wrapped_row_within_align_items_center.rs +59 −0
- tests/generated/wrapped_row_within_align_items_flex_end.rs +59 −0
- tests/generated/wrapped_row_within_align_items_flex_start.rs +59 −0
diff --git a/tests/generated.rs b/tests/generated.rs
index df89457fc..6827431c7 100644
--- a/tests/generated.rs
+++ b/tests/generated.rs
@@ -1,12161 +1,240 @@
-#[cfg(test)]
mod generated {
- #[test]
- fn justify_content_row_space_around() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::SpaceAround,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 12.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 45.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 78.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn align_items_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 45.0000);
- }
-
- #[test]
- fn absolute_layout_justify_content_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 25.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_bottom_and_top() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Auto,
- bottom: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn margin_auto_left_and_right_strech() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- end: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn rounding_flex_basis_overrides_main_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(113.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 113.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 64.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 25.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 64.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 24.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn percentage_flex_basis() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.2500),
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 125.0000);
- assert_eq!(layout.children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 75.0000);
- assert_eq!(layout.children[1].size.height, 200.0000);
- assert_eq!(layout.children[1].location.x, 125.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn rounding_fractial_input_3() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(113.4000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 113.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 64.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 25.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 64.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 24.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn margin_and_stretch_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn wrapped_column_max_height_flex() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::Wrap,
- align_items: stretch::style::AlignItems::Center,
- align_content: stretch::style::AlignContent::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(700.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(20.0000),
- end: stretch::style::Dimension::Points(20.0000),
- top: stretch::style::Dimension::Points(20.0000),
- bottom: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 700.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 180.0000);
- assert_eq!(layout.children[0].location.x, 300.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 200.0000);
- assert_eq!(layout.children[1].size.height, 180.0000);
- assert_eq!(layout.children[1].location.x, 250.0000);
- assert_eq!(layout.children[1].location.y, 200.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 300.0000);
- assert_eq!(layout.children[2].location.y, 400.0000);
- }
-
- #[test]
- fn align_baseline_nested_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Baseline,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 40.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 50.0000);
- assert_eq!(layout.children[1].children[0].size.height, 10.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn max_height_overrides_height_on_root() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
- }
-
- #[test]
- fn padding_center_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(20.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 40.0000);
- assert_eq!(layout.children[0].location.y, 40.0000);
- }
-
- #[test]
- fn align_flex_start_with_stretching_children() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 500.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 500.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].children[0].size.height, 500.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 500.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn min_width_overrides_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 0.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_wrap_align_stretch_fits_one_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(150.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 150.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_space_evenly() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::SpaceEvenly,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 25.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 0.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 0.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 75.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_child_order() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 55.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
-
- assert_eq!(layout.children[1].size.width, 60.0000);
- assert_eq!(layout.children[1].size.height, 40.0000);
- assert_eq!(layout.children[1].location.x, 25.0000);
- assert_eq!(layout.children[1].location.y, 30.0000);
-
- assert_eq!(layout.children[2].size.width, 55.0000);
- assert_eq!(layout.children[2].size.height, 40.0000);
- assert_eq!(layout.children[2].location.x, 55.0000);
- assert_eq!(layout.children[2].location.y, 30.0000);
- }
-
- #[test]
- fn absolute_layout_percentage_bottom_based_on_parent_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- top: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- bottom: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- top: stretch::style::Dimension::Percent(0.1000),
- bottom: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 100.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 90.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 160.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
- }
-
- #[test]
- fn absolute_layout_align_items_and_justify_content_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexEnd,
- justify_content: stretch::style::JustifyContent::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 60.0000);
- }
-
- #[test]
- fn nested_overflowing_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_direction_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 10.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 20.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn child_min_max_width_flexing() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(120.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 0.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 0.0000,
- flex_basis: stretch::style::Dimension::Percent(0.5000),
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 120.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 20.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 100.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_in_wrap_reverse_row_container_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- align_self: stretch::style::AlignSelf::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_and_flex_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn flex_basis_flex_shrink_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 67.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 33.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 67.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_column_min_height_and_margin_top() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- justify_content: stretch::style::JustifyContent::Center,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 20.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 20.0000);
- }
-
- #[test]
- fn justify_content_overflow_min_max() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- justify_content: stretch::style::JustifyContent::Center,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(110.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_shrink: 0.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_shrink: 0.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_shrink: 0.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 110.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, -20.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 30.0000);
-
- assert_eq!(layout.children[2].size.width, 50.0000);
- assert_eq!(layout.children[2].size.height, 50.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 80.0000);
- }
-
- #[test]
- fn wrap_reverse_column_fixed_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 135.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 135.0000);
- assert_eq!(layout.children[1].location.y, 10.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 135.0000);
- assert_eq!(layout.children[2].location.y, 30.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 40.0000);
- assert_eq!(layout.children[3].location.x, 135.0000);
- assert_eq!(layout.children[3].location.y, 60.0000);
-
- assert_eq!(layout.children[4].size.width, 30.0000);
- assert_eq!(layout.children[4].size.height, 50.0000);
- assert_eq!(layout.children[4].location.x, 35.0000);
- assert_eq!(layout.children[4].location.y, 0.0000);
- }
-
- #[test]
- fn max_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 35.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 45.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 55.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn flex_grow_root_minimized() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 300.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 300.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 100.0000);
- assert_eq!(layout.children[0].children[1].size.height, 100.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 200.0000);
- }
-
- #[test]
- fn container_with_unsized_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node { ..Default::default() }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_grow_within_constrained_min_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_shrink_by_outer_margin_with_max_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 20.0000);
- assert_eq!(layout.size.height, 80.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 100.0000);
- }
-
- #[test]
- fn absolute_layout_width_height_start_top_end_bottom() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn overflow_main_axis() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_shrink: 0.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_grow_to_min() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node { flex_grow: 1.0000, flex_shrink: 1.0000, ..Default::default() },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 50.0000);
- }
-
- #[test]
- fn absolute_layout_align_items_and_justify_content_center_and_top_position() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 25.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn min_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(60.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 80.0000);
- }
-
- #[test]
- fn justify_content_column_flex_start() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 10.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
- }
-
- #[test]
- fn absolute_layout_in_wrap_reverse_column_container() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 80.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_should_not_be_part_of_max_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(250.0000),
- height: stretch::style::Dimension::Points(250.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 250.0000);
- assert_eq!(layout.size.height, 250.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 20.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_no_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn border_flex_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- border: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn wrap_reverse_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(31.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(32.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(33.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(34.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 60.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 31.0000);
- assert_eq!(layout.children[0].size.height, 30.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
-
- assert_eq!(layout.children[1].size.width, 32.0000);
- assert_eq!(layout.children[1].size.height, 30.0000);
- assert_eq!(layout.children[1].location.x, 31.0000);
- assert_eq!(layout.children[1].location.y, 30.0000);
-
- assert_eq!(layout.children[2].size.width, 33.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 63.0000);
- assert_eq!(layout.children[2].location.y, 30.0000);
-
- assert_eq!(layout.children[3].size.width, 34.0000);
- assert_eq!(layout.children[3].size.height, 30.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 0.0000);
- }
-
- #[test]
- fn margin_right() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 80.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn display_none_with_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- ..Default::default()
- },
- stretch::style::Node {
- display: stretch::style::Display::None,
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 0.0000);
- assert_eq!(layout.children[1].size.height, 0.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 0.0000);
- assert_eq!(layout.children[1].children[0].size.height, 0.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 50.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 50.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn align_flex_start_with_shrinking_children_with_stretch() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexStart,
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 500.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 500.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_smaller_then_content_with_flex_grow_large_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 70.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_items_stretch() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn parent_wrap_child_size_overflowing_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn padding_stretch_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn wrap_nodes_with_content_sizing_overflowing_margin() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(85.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(40.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- margin: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(40.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 500.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 85.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 40.0000);
- assert_eq!(layout.children[0].children[1].size.height, 40.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 40.0000);
-
- assert_eq!(layout.children[0].children[1].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[1].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_shrink_flex_grow_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 0.0000,
- flex_shrink: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 0.0000,
- flex_shrink: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 500.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 250.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 250.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 250.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_flex_shrink_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 67.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 33.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 67.0000);
- }
-
- #[test]
- fn align_items_min_max() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(60.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 60.0000);
- assert_eq!(layout.children[0].location.x, 20.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_smaller_then_content_with_flex_grow_unconstraint_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 90.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 20.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 70.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_min_width_and_margin() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 20.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 20.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_self_flex_start() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_self: stretch::style::AlignSelf::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_position_left_top() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(400.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.4500),
- height: stretch::style::Dimension::Percent(0.5500),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Percent(0.1000),
- top: stretch::style::Dimension::Percent(0.2000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 400.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 180.0000);
- assert_eq!(layout.children[0].size.height, 220.0000);
- assert_eq!(layout.children[0].location.x, 40.0000);
- assert_eq!(layout.children[0].location.y, 80.0000);
- }
-
- #[test]
- fn border_stretch_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- border: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn rounding_fractial_input_2() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(113.6000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 114.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 65.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 24.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 65.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 25.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn percentage_flex_basis_main_max_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1500),
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.6000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 4.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1000),
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.2000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 120.0000);
- assert_eq!(layout.children[0].size.height, 400.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 40.0000);
- assert_eq!(layout.children[1].size.height, 400.0000);
- assert_eq!(layout.children[1].location.x, 120.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_top_and_bottom_strech() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Auto,
- bottom: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 50.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 150.0000);
- }
-
- #[test]
- fn percentage_multiple_nested_with_padding_margin_and_percentage_values() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1000),
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.6000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(5.0000),
- end: stretch::style::Dimension::Points(5.0000),
- top: stretch::style::Dimension::Points(5.0000),
- bottom: stretch::style::Dimension::Points(5.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(3.0000),
- end: stretch::style::Dimension::Points(3.0000),
- top: stretch::style::Dimension::Points(3.0000),
- bottom: stretch::style::Dimension::Points(3.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(5.0000),
- end: stretch::style::Dimension::Points(5.0000),
- top: stretch::style::Dimension::Points(5.0000),
- bottom: stretch::style::Dimension::Points(5.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Percent(0.0300),
- end: stretch::style::Dimension::Percent(0.0300),
- top: stretch::style::Dimension::Percent(0.0300),
- bottom: stretch::style::Dimension::Percent(0.0300),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.4500),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Percent(0.0500),
- end: stretch::style::Dimension::Percent(0.0500),
- top: stretch::style::Dimension::Percent(0.0500),
- bottom: stretch::style::Dimension::Percent(0.0500),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(3.0000),
- end: stretch::style::Dimension::Points(3.0000),
- top: stretch::style::Dimension::Points(3.0000),
- bottom: stretch::style::Dimension::Points(3.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 4.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1500),
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.2000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 190.0000);
- assert_eq!(layout.children[0].size.height, 48.0000);
- assert_eq!(layout.children[0].location.x, 5.0000);
- assert_eq!(layout.children[0].location.y, 5.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 92.0000);
- assert_eq!(layout.children[0].children[0].size.height, 25.0000);
- assert_eq!(layout.children[0].children[0].location.x, 8.0000);
- assert_eq!(layout.children[0].children[0].location.y, 8.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 36.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 6.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 10.0000);
-
- assert_eq!(layout.children[1].size.width, 200.0000);
- assert_eq!(layout.children[1].size.height, 142.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 58.0000);
- }
-
- #[test]
- fn flex_grow_within_constrained_min_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 0.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 50.0000);
- }
-
- #[test]
- fn flex_grow_in_at_most_container() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_left() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 100.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn percentage_flex_basis_cross() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.2500),
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 250.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 200.0000);
- assert_eq!(layout.children[1].size.height, 150.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 250.0000);
- }
-
- #[test]
- fn percentage_absolute_position() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Percent(0.3000),
- top: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 60.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn flex_basis_flex_grow_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 75.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 25.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 75.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_in_wrap_reverse_column_container_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- align_self: stretch::style::AlignSelf::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_flex_start() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 10.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 20.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_left_right_child_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(52.0000),
- height: stretch::style::Dimension::Points(52.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(72.0000),
- height: stretch::style::Dimension::Points(72.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- end: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 52.0000);
- assert_eq!(layout.size.height, 52.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 52.0000);
- assert_eq!(layout.children[0].size.height, 72.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_larger_than_content_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_fix_left_auto_right_child_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(52.0000),
- height: stretch::style::Dimension::Points(52.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(72.0000),
- height: stretch::style::Dimension::Points(72.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 52.0000);
- assert_eq!(layout.size.height, 52.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 42.0000);
- assert_eq!(layout.children[0].size.height, 72.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_container_in_wrapping_container() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- children: vec![stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(1.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[1].size.width, 50.0000);
- assert_eq!(layout.children[0].children[0].children[1].size.height, 50.0000);
- assert_eq!(layout.children[0].children[0].children[1].location.x, 50.0000);
- assert_eq!(layout.children[0].children[0].children[1].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_left_stretching_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.0000),
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 150.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 100.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn flex_basis_smaller_then_content_with_flex_grow_small_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 10.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 20.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 70.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_flex_basis_cross_max_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1000),
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.6000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 4.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1500),
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.2000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 120.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 40.0000);
- assert_eq!(layout.children[1].size.height, 300.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 100.0000);
- }
-
- #[test]
- fn align_items_flex_end_child_without_margin_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexEnd,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(70.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 70.0000);
- assert_eq!(layout.children[0].location.x, -10.0000);
- assert_eq!(layout.children[0].location.y, -10.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 70.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn width_smaller_then_content_with_flex_grow_very_large_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 100.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn size_defined_by_child_with_padding() {
- let layout = stretch::compute(
- &stretch::style::Node {
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 30.0000);
- assert_eq!(layout.size.height, 30.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn absolute_layout_within_border() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- border: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(0.0000),
- top: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(0.0000),
- bottom: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(0.0000),
- top: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(0.0000),
- bottom: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 40.0000);
- assert_eq!(layout.children[1].location.y, 40.0000);
-
- assert_eq!(layout.children[2].size.width, 50.0000);
- assert_eq!(layout.children[2].size.height, 50.0000);
- assert_eq!(layout.children[2].location.x, 20.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
-
- assert_eq!(layout.children[3].size.width, 50.0000);
- assert_eq!(layout.children[3].size.height, 50.0000);
- assert_eq!(layout.children[3].location.x, 30.0000);
- assert_eq!(layout.children[3].location.y, 30.0000);
- }
-
- #[test]
- fn margin_auto_left_fix_right_child_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(52.0000),
- height: stretch::style::Dimension::Points(52.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(72.0000),
- height: stretch::style::Dimension::Points(72.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 52.0000);
- assert_eq!(layout.size.height, 52.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 42.0000);
- assert_eq!(layout.children[0].size.height, 72.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 70.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 80.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 90.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn margin_bottom() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- justify_content: stretch::style::JustifyContent::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 80.0000);
- }
-
- #[test]
- fn margin_should_not_be_part_of_max_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(250.0000),
- height: stretch::style::Dimension::Points(250.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 250.0000);
- assert_eq!(layout.size.height, 250.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 20.0000);
- }
-
- #[test]
- fn flex_basis_smaller_than_main_dimen_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(10.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_flex_basis_cross_min_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Percent(0.6000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 2.0000,
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 280.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 200.0000);
- assert_eq!(layout.children[1].size.height, 120.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 280.0000);
- }
-
- #[test]
- fn nested_overflowing_child_in_constraint_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn wrapped_row_within_align_items_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(150.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(80.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 160.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 150.0000);
- assert_eq!(layout.children[0].children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 80.0000);
- assert_eq!(layout.children[0].children[1].size.height, 80.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 80.0000);
- }
-
- #[test]
- fn justify_content_column_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 35.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 45.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 55.0000);
- }
-
- #[test]
- fn align_items_center_child_with_margin_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, -10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_width_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.3000),
- height: stretch::style::Dimension::Percent(0.3000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 120.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_mutiple_children_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 75.0000);
- assert_eq!(layout.children[0].location.y, 25.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 75.0000);
- assert_eq!(layout.children[1].location.y, 100.0000);
-
- assert_eq!(layout.children[2].size.width, 50.0000);
- assert_eq!(layout.children[2].size.height, 50.0000);
- assert_eq!(layout.children[2].location.x, 75.0000);
- assert_eq!(layout.children[2].location.y, 150.0000);
- }
-
- #[test]
- fn min_width_overrides_width_on_root() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 0.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
- }
-
- #[test]
- fn flex_wrap_wrap_to_child_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- children: vec![
- stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- align_items: stretch::style::AlignItems::FlexStart,
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 100.0000);
- }
-
- #[test]
- fn wrap_nodes_with_content_sizing_margin_cross() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(500.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(40.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(40.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 500.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 90.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 40.0000);
- assert_eq!(layout.children[0].children[1].size.height, 40.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 50.0000);
-
- assert_eq!(layout.children[0].children[1].children[0].size.width, 40.0000);
- assert_eq!(layout.children[0].children[1].children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_baseline() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Baseline,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 30.0000);
- }
-
- #[test]
- fn margin_with_sibling_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 45.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 45.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 55.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn wrap_reverse_row_align_content_space_around() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- align_content: stretch::style::AlignContent::SpaceAround,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 80.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 70.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 60.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 50.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 40.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 10.0000);
-
- assert_eq!(layout.children[4].size.width, 30.0000);
- assert_eq!(layout.children[4].size.height, 50.0000);
- assert_eq!(layout.children[4].location.x, 30.0000);
- assert_eq!(layout.children[4].location.y, 0.0000);
- }
-
- #[test]
- fn wrap_reverse_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(31.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(32.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(33.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(34.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 31.0000);
- assert_eq!(layout.children[0].location.x, 70.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 32.0000);
- assert_eq!(layout.children[1].location.x, 70.0000);
- assert_eq!(layout.children[1].location.y, 31.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 33.0000);
- assert_eq!(layout.children[2].location.x, 70.0000);
- assert_eq!(layout.children[2].location.y, 63.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 34.0000);
- assert_eq!(layout.children[3].location.x, 20.0000);
- assert_eq!(layout.children[3].location.y, 0.0000);
- }
-
- #[test]
- fn align_items_center_with_child_margin() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 50.0000);
- }
-
- #[test]
- fn flex_direction_column_reverse() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::ColumnReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 90.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 80.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 70.0000);
- }
-
- #[test]
- fn flex_direction_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 10.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
- }
-
- #[test]
- fn align_items_center_child_without_margin_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(70.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 70.0000);
- assert_eq!(layout.children[0].location.x, -10.0000);
- assert_eq!(layout.children[0].location.y, -10.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 70.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_self_flex_end_override_flex_start() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_self: stretch::style::AlignSelf::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 90.0000);
- }
-
- #[test]
- fn rounding_total_fractial() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(87.4000),
- height: stretch::style::Dimension::Points(113.4000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 0.7000,
- flex_basis: stretch::style::Dimension::Points(50.3000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.3000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.6000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.1000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.7000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 87.0000);
- assert_eq!(layout.size.height, 113.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 87.0000);
- assert_eq!(layout.children[0].size.height, 59.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 87.0000);
- assert_eq!(layout.children[1].size.height, 30.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 59.0000);
-
- assert_eq!(layout.children[2].size.width, 87.0000);
- assert_eq!(layout.children[2].size.height, 24.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn align_baseline_child_multiline() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Baseline,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(60.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(25.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(25.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(25.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(25.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 80.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 60.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 40.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 40.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 25.0000);
- assert_eq!(layout.children[1].children[0].size.height, 20.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[1].size.width, 25.0000);
- assert_eq!(layout.children[1].children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].children[1].location.x, 25.0000);
- assert_eq!(layout.children[1].children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[2].size.width, 25.0000);
- assert_eq!(layout.children[1].children[2].size.height, 20.0000);
- assert_eq!(layout.children[1].children[2].location.x, 0.0000);
- assert_eq!(layout.children[1].children[2].location.y, 20.0000);
-
- assert_eq!(layout.children[1].children[3].size.width, 25.0000);
- assert_eq!(layout.children[1].children[3].size.height, 10.0000);
- assert_eq!(layout.children[1].children[3].location.x, 25.0000);
- assert_eq!(layout.children[1].children[3].location.y, 20.0000);
- }
-
- #[test]
- fn absolute_layout_align_items_center_on_child_only() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- align_self: stretch::style::AlignSelf::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
- }
-
- #[test]
- fn wrap_reverse_row_single_line_different_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- align_content: stretch::style::AlignContent::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(300.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 300.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 40.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 30.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 40.0000);
- assert_eq!(layout.children[3].location.x, 90.0000);
- assert_eq!(layout.children[3].location.y, 10.0000);
-
- assert_eq!(layout.children[4].size.width, 30.0000);
- assert_eq!(layout.children[4].size.height, 50.0000);
- assert_eq!(layout.children[4].location.x, 120.0000);
- assert_eq!(layout.children[4].location.y, 0.0000);
- }
-
- #[test]
- fn rounding_fractial_input_4() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(113.4000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 113.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 64.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 25.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 64.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 24.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn width_smaller_then_content_with_flex_grow_unconstraint_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 0.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn padding_flex_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn flex_direction_row_reverse() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::RowReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 90.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 80.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 70.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_size_based_on_parent_inner_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(20.0000),
- end: stretch::style::Dimension::Points(20.0000),
- top: stretch::style::Dimension::Points(20.0000),
- bottom: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.5000),
- height: stretch::style::Dimension::Percent(0.5000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 180.0000);
- assert_eq!(layout.children[0].location.x, 20.0000);
- assert_eq!(layout.children[0].location.y, 20.0000);
- }
-
- #[test]
- fn wrap_reverse_row_align_content_stretch() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 80.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 70.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 60.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 50.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 40.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 10.0000);
-
- assert_eq!(layout.children[4].size.width, 30.0000);
- assert_eq!(layout.children[4].size.height, 50.0000);
- assert_eq!(layout.children[4].location.x, 30.0000);
- assert_eq!(layout.children[4].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_top() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect { top: stretch::style::Dimension::Auto, ..Default::default() },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 150.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn flex_grow_within_constrained_max_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_shrink: 1.0000,
- flex_basis: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 67.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 33.0000);
- assert_eq!(layout.children[0].children[1].size.height, 100.0000);
- assert_eq!(layout.children[0].children[1].location.x, 67.0000);
- assert_eq!(layout.children[0].children[1].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_align_items_and_justify_content_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 25.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
- }
-
- #[test]
- fn align_self_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_self: stretch::style::AlignSelf::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 90.0000);
- }
-
- #[test]
- fn margin_auto_left_child_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(52.0000),
- height: stretch::style::Dimension::Points(52.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(72.0000),
- height: stretch::style::Dimension::Points(72.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect { start: stretch::style::Dimension::Auto, ..Default::default() },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 52.0000);
- assert_eq!(layout.size.height, 52.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 52.0000);
- assert_eq!(layout.children[0].size.height, 72.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn wrapped_row_within_align_items_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(150.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(80.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 160.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 150.0000);
- assert_eq!(layout.children[0].children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 80.0000);
- assert_eq!(layout.children[0].children[1].size.height, 80.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 80.0000);
- }
-
- #[test]
- fn min_height_overrides_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_strech_should_size_based_on_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- flex_grow: 0.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn wrap_row_align_items_flex_end() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- align_items: stretch::style::AlignItems::FlexEnd,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 60.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 20.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 10.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 30.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 30.0000);
- }
-
- #[test]
- fn size_defined_by_child_with_border() {
- let layout = stretch::compute(
- &stretch::style::Node {
- border: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 30.0000);
- assert_eq!(layout.size.height, 30.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn margin_auto_bottom_and_top_justify_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Auto,
- bottom: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 100.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_overrides_main_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 20.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 60.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 20.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 80.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn wrapped_row_within_align_items_flex_start() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(150.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(80.0000),
- height: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 200.0000);
- assert_eq!(layout.children[0].size.height, 160.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 150.0000);
- assert_eq!(layout.children[0].children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 80.0000);
- assert_eq!(layout.children[0].children[1].size.height, 80.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 80.0000);
- }
-
- #[test]
- fn align_center_should_size_based_on_content() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- flex_grow: 0.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_shrink: 1.0000,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 40.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].children[0].children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_right() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect { end: stretch::style::Dimension::Auto, ..Default::default() },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn wrap_reverse_row_align_content_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- align_content: stretch::style::AlignContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 80.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 70.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 60.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 50.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 40.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 10.0000);
-
- assert_eq!(layout.children[4].size.width, 30.0000);
- assert_eq!(layout.children[4].size.height, 50.0000);
- assert_eq!(layout.children[4].location.x, 30.0000);
- assert_eq!(layout.children[4].location.y, 0.0000);
- }
-
- #[test]
- fn padding_no_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- padding: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 20.0000);
- assert_eq!(layout.size.height, 20.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
- }
-
- #[test]
- fn margin_with_sibling_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 45.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 45.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 55.0000);
- }
-
- #[test]
- fn flex_direction_row_no_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 30.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 10.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 10.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 10.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 20.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn max_width_overrides_width_on_root() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 0.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_left_and_right() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- end: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_direction_column_no_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 30.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 10.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 10.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 10.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 20.0000);
- }
-
- #[test]
- fn flex_basis_unconstraint_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- children: vec![stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn width_smaller_then_content_with_flex_grow_small_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 10.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 5.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 5.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 5.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_in_wrap_reverse_row_container() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::WrapReverse,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 20.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 80.0000);
- }
-
- #[test]
- fn flex_basis_and_main_dimen_set_when_flexing() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(10.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(10.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(0.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 50.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_smaller_than_main_dimen_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(10.0000),
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_margin_should_calculate_based_only_on_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Percent(0.1000),
- end: stretch::style::Dimension::Percent(0.1000),
- top: stretch::style::Dimension::Percent(0.1000),
- bottom: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 160.0000);
- assert_eq!(layout.children[0].size.height, 60.0000);
- assert_eq!(layout.children[0].location.x, 20.0000);
- assert_eq!(layout.children[0].location.y, 20.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_start_top_end_bottom() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- position: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn min_width() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 20.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 80.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn min_height_overrides_height_on_root() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
- }
-
- #[test]
- fn absolute_layout_width_height_end_bottom() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 80.0000);
- assert_eq!(layout.children[0].location.y, 80.0000);
- }
-
- #[test]
- fn align_self_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_self: stretch::style::AlignSelf::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 45.0000);
- }
-
- #[test]
- fn wrapped_column_max_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::Wrap,
- align_items: stretch::style::AlignItems::Center,
- align_content: stretch::style::AlignContent::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(700.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(500.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(20.0000),
- end: stretch::style::Dimension::Points(20.0000),
- top: stretch::style::Dimension::Points(20.0000),
- bottom: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 700.0000);
- assert_eq!(layout.size.height, 500.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].location.x, 250.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
-
- assert_eq!(layout.children[1].size.width, 200.0000);
- assert_eq!(layout.children[1].size.height, 200.0000);
- assert_eq!(layout.children[1].location.x, 200.0000);
- assert_eq!(layout.children[1].location.y, 250.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 420.0000);
- assert_eq!(layout.children[2].location.y, 200.0000);
- }
-
- #[test]
- fn wrap_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(31.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(32.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(33.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(34.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 60.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 31.0000);
- assert_eq!(layout.children[0].size.height, 30.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 32.0000);
- assert_eq!(layout.children[1].size.height, 30.0000);
- assert_eq!(layout.children[1].location.x, 31.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 33.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 63.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
-
- assert_eq!(layout.children[3].size.width, 34.0000);
- assert_eq!(layout.children[3].size.height, 30.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 30.0000);
- }
-
- #[test]
- fn max_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_grow_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 0.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percentage_size_of_flex_basis() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(1.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn align_items_flex_end_child_with_margin_bigger_than_parent() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- align_items: stretch::style::AlignItems::FlexEnd,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 50.0000);
- assert_eq!(layout.size.height, 50.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, -10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn justify_content_row_max_width_and_margin() {
- let layout = stretch::compute(
- &stretch::style::Node {
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(80.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 80.0000);
- assert_eq!(layout.size.height, 20.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 20.0000);
- assert_eq!(layout.children[0].location.x, 90.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn margin_left() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn size_defined_by_child() {
- let layout = stretch::compute(
- &stretch::style::Node {
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn rounding_total_fractial_nested() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(87.4000),
- height: stretch::style::Dimension::Points(113.4000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 0.7000,
- flex_basis: stretch::style::Dimension::Points(50.3000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(20.3000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.3000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(9.9000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- bottom: stretch::style::Dimension::Points(13.3000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 4.0000,
- flex_basis: stretch::style::Dimension::Points(0.3000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(1.1000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(13.3000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.6000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 1.1000,
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.7000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 87.0000);
- assert_eq!(layout.size.height, 113.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 87.0000);
- assert_eq!(layout.children[0].size.height, 59.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 87.0000);
- assert_eq!(layout.children[0].children[0].size.height, 12.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, -13.0000);
-
- assert_eq!(layout.children[0].children[1].size.width, 87.0000);
- assert_eq!(layout.children[0].children[1].size.height, 47.0000);
- assert_eq!(layout.children[0].children[1].location.x, 0.0000);
- assert_eq!(layout.children[0].children[1].location.y, 25.0000);
-
- assert_eq!(layout.children[1].size.width, 87.0000);
- assert_eq!(layout.children[1].size.height, 30.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 59.0000);
-
- assert_eq!(layout.children[2].size.width, 87.0000);
- assert_eq!(layout.children[2].size.height, 24.0000);
- assert_eq!(layout.children[2].location.x, 0.0000);
- assert_eq!(layout.children[2].location.y, 89.0000);
- }
-
- #[test]
- fn min_max_percent_no_width_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- align_items: stretch::style::AlignItems::FlexStart,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.1000),
- height: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- max_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(0.1000),
- height: stretch::style::Dimension::Percent(0.1000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 10.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_smaller_then_content_with_flex_grow_very_large_size() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(70.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(0.0000),
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[0].children[0].size.width, 70.0000);
- assert_eq!(layout.children[0].children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 100.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 20.0000);
- assert_eq!(layout.children[1].children[0].size.height, 100.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
- }
-
- #[test]
- fn percent_within_flex_grow() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(350.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_grow: 1.0000,
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Percent(1.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 350.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 150.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 100.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
-
- assert_eq!(layout.children[1].children[0].size.width, 150.0000);
- assert_eq!(layout.children[1].children[0].size.height, 0.0000);
- assert_eq!(layout.children[1].children[0].location.x, 0.0000);
- assert_eq!(layout.children[1].children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[2].size.width, 100.0000);
- assert_eq!(layout.children[2].size.height, 100.0000);
- assert_eq!(layout.children[2].location.x, 250.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
- }
-
- #[test]
- fn margin_and_stretch_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 80.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn margin_top() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
- }
-
- #[test]
- fn percentage_flex_basis_main_max_height() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(400.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1000),
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Percent(0.6000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_grow: 4.0000,
- flex_basis: stretch::style::Dimension::Percent(0.1000),
- max_size: stretch::geometry::Size {
- height: stretch::style::Dimension::Percent(0.2000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 400.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 52.0000);
- assert_eq!(layout.children[0].size.height, 240.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 148.0000);
- assert_eq!(layout.children[1].size.height, 80.0000);
- assert_eq!(layout.children[1].location.x, 52.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn margin_auto_left_and_right_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(200.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Auto,
- end: stretch::style::Dimension::Auto,
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(50.0000),
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 200.0000);
- assert_eq!(layout.size.height, 200.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 50.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 50.0000);
- assert_eq!(layout.children[0].location.y, 75.0000);
-
- assert_eq!(layout.children[1].size.width, 50.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 150.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn margin_and_flex_row() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- flex_grow: 1.0000,
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 80.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 10.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn flex_wrap_children_with_min_main_overriding_flex_basis() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(55.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- flex_basis: stretch::style::Dimension::Points(50.0000),
- size: stretch::geometry::Size {
- height: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- min_size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(55.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 55.0000);
- assert_eq!(layout.children[0].size.height, 50.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 55.0000);
- assert_eq!(layout.children[1].size.height, 50.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 50.0000);
- }
-
- #[test]
- fn wrap_row_align_items_center() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_wrap: stretch::style::FlexWrap::Wrap,
- align_items: stretch::style::AlignItems::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(30.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 60.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 10.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 10.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 20.0000);
- assert_eq!(layout.children[1].location.x, 30.0000);
- assert_eq!(layout.children[1].location.y, 5.0000);
-
- assert_eq!(layout.children[2].size.width, 30.0000);
- assert_eq!(layout.children[2].size.height, 30.0000);
- assert_eq!(layout.children[2].location.x, 60.0000);
- assert_eq!(layout.children[2].location.y, 0.0000);
-
- assert_eq!(layout.children[3].size.width, 30.0000);
- assert_eq!(layout.children[3].size.height, 30.0000);
- assert_eq!(layout.children[3].location.x, 0.0000);
- assert_eq!(layout.children[3].location.y, 30.0000);
- }
-
- #[test]
- fn display_none_with_margin() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- display: stretch::style::Display::None,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(20.0000),
- height: stretch::style::Dimension::Points(20.0000),
- ..Default::default()
- },
- margin: stretch::geometry::Rect {
- start: stretch::style::Dimension::Points(10.0000),
- end: stretch::style::Dimension::Points(10.0000),
- top: stretch::style::Dimension::Points(10.0000),
- bottom: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 0.0000);
- assert_eq!(layout.children[0].size.height, 0.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 100.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn flex_basis_flex_grow_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- flex_grow: 1.0000,
- flex_basis: stretch::style::Dimension::Points(50.0000),
- ..Default::default()
- },
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 75.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 100.0000);
- assert_eq!(layout.children[1].size.height, 25.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 75.0000);
- }
-
- #[test]
- fn absolute_layout_align_items_and_justify_content_center_and_right_position() {
- let layout = stretch::compute(
- &stretch::style::Node {
- align_items: stretch::style::AlignItems::Center,
- justify_content: stretch::style::JustifyContent::Center,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(110.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- position_type: stretch::style::PositionType::Absolute,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(60.0000),
- height: stretch::style::Dimension::Points(40.0000),
- ..Default::default()
- },
- position: stretch::geometry::Rect {
- end: stretch::style::Dimension::Points(5.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 110.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 60.0000);
- assert_eq!(layout.children[0].size.height, 40.0000);
- assert_eq!(layout.children[0].location.x, 45.0000);
- assert_eq!(layout.children[0].location.y, 30.0000);
- }
-
- #[test]
- fn overflow_cross_axis() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(200.0000),
- ..Default::default()
- },
- ..Default::default()
- }],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 200.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
- }
-
- #[test]
- fn display_none_with_position() {
- let layout = stretch::compute(
- &stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node { flex_grow: 1.0000, ..Default::default() },
- stretch::style::Node {
- display: stretch::style::Display::None,
- flex_grow: 1.0000,
- position: stretch::geometry::Rect {
- top: stretch::style::Dimension::Points(10.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 100.0000);
- assert_eq!(layout.children[0].size.height, 100.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 0.0000);
- assert_eq!(layout.children[1].size.height, 0.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 0.0000);
- }
-
- #[test]
- fn wrap_column() {
- let layout = stretch::compute(
- &stretch::style::Node {
- flex_direction: stretch::style::FlexDirection::Column,
- flex_wrap: stretch::style::FlexWrap::Wrap,
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(100.0000),
- height: stretch::style::Dimension::Points(100.0000),
- ..Default::default()
- },
- children: vec![
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(31.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(32.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(33.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- stretch::style::Node {
- size: stretch::geometry::Size {
- width: stretch::style::Dimension::Points(30.0000),
- height: stretch::style::Dimension::Points(34.0000),
- ..Default::default()
- },
- ..Default::default()
- },
- ],
- ..Default::default()
- },
- stretch::geometry::Size::undefined(),
- )
- .unwrap();
-
- assert_eq!(layout.size.width, 100.0000);
- assert_eq!(layout.size.height, 100.0000);
- assert_eq!(layout.location.x, 0.0000);
- assert_eq!(layout.location.y, 0.0000);
-
- assert_eq!(layout.children[0].size.width, 30.0000);
- assert_eq!(layout.children[0].size.height, 31.0000);
- assert_eq!(layout.children[0].location.x, 0.0000);
- assert_eq!(layout.children[0].location.y, 0.0000);
-
- assert_eq!(layout.children[1].size.width, 30.0000);
- assert_eq!(layout.children[1].size.height, 32.0000);
- assert_eq!(layout.children[1].location.x, 0.0000);
- assert_eq!(layout.children[1].location.y, 31.0000);
-
- assert_eq!(layout.children[2].size.wi
El parche sigue, pero se cortó acá: pedí el commit por git para verlo entero.