Add experiment support to gentest

Summary:
This diff does two things
- Clean up some of the generated code making the files smaller.
- Add experiment support to generated tests allowing us to use gentest for things still being experimented with such as more compliant flex-basis behavior.

Reviewed By: gkassabli

Differential Revision: D4226734

fbshipit-source-id: 2cc1471c21883e8e326f16e7a8bb1a3657acd84b
This commit is contained in:
Emil Sjolander
2016-11-23 11:12:51 -08:00
committed by Facebook Github Bot
parent a0d560a24b
commit 22b0fdb3e6
49 changed files with 6574 additions and 6119 deletions

View File

@@ -7,37 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="absolute_layout_width_height_start_top" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px;"></div>
</div>
<div id="absolute_layout_width_height_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; end: 10px; bottom: 10px;"></div>
</div>
<div id="absolute_layout_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="absolute_layout_width_height_start_top_end_bottom" style="width: 100px; height: 100px;">
<div style="width:10px; height: 10px; position: absolute; start: 10px; top: 10px; end: 10px; bottom: 10px;"></div>
</div>
<div id="do_not_clamp_height_of_absolute_node_to_height_of_its_overflow_hidden_parent" style="height: 50px; width: 50px; overflow: hidden; flex-direction: row;">
<div style="position: absolute; start: 0px; top: 0px;">
<div style="width: 100px; height: 100px;"></div>
</div>
</div>
<div id="absolute_layout_within_border" style="height:100px; width:100px; border-width: 10px; margin: 10px; padding: 10px;">
<div style="position: absolute; width: 50px; height: 50px; left: 0px; top: 0px;"></div>
<div style="position: absolute; width: 50px; height: 50px; right: 0px; bottom: 0px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAbsolutePositionTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,42 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_content_flex_start" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-start;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_flex_end" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: flex-end;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_center" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: center;">
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
<div style="width: 50px; height: 10px;"></div>
</div>
<div id="align_content_stretch" style="width: 100px; height: 100px; flex-wrap: wrap; flex-direction: column; align-content: stretch;">
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
<div style="width: 50px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignContentTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_items_stretch" style="width: 100px; height: 100px;">
<div style="height: 10px;"></div>
</div>
<div id="align_items_center" style="width: 100px; height: 100px; align-items: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_start" style="width: 100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px;"></div>
</div>
<div id="align_items_flex_end" style="width: 100px; height: 100px; align-items: flex-end;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignItemsTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,26 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="align_self_center" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: center;"></div>
</div>
<div id="align_self_flex_end" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
<div id="align_self_flex_start" style="width:100px; height: 100px;">
<div style="height: 10px; width: 10px; align-self: flex-start;"></div>
</div>
<div id="align_self_flex_end_override_flex_start" style="width:100px; height: 100px; align-items: flex-start;">
<div style="height: 10px; width: 10px; align-self: flex-end;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutAlignSelfTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="border_no_size" style="border-width: 10px;">
</div>
<div id="border_container_match_child" style="border-width: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="border_flex_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="border_stretch_child" style="width: 100px; height: 100px; border-width: 10px;">
<div style="height: 10px;"></div>
</div>
<div id="border_center_child" style="width: 100px; height: 100px; border-start-width: 10px; border-top-width: 10; border-end-width: 20px; border-bottom-width: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutBorderTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,46 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_direction_column_no_height" style="width: 100px">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_no_width" style="height: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column" style="height: 100px; width: 100px;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row" style="height: 100px; width: 100px; flex-direction: row;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="flex_direction_column_reverse" style="height: 100px; width: 100px; flex-direction: column-reverse;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="flex_direction_row_reverse" style="height: 100px; width: 100px; flex-direction: row-reverse;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexDirectionTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,48 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="flex_basis_flex_grow_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_grow_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 50px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="flex_basis_flex_shrink_column" style="width: 100px; height: 100px;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_basis_flex_shrink_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 50px;"></div>
</div>
<div id="flex_shrink_to_zero" style="height: 75px;">
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
<div style="width: 50px; height: 50px; flex-shrink:1;"></div>
<div style="width: 50px; height: 50px; flex-shrink:0;"></div>
</div>
<div id="flex_basis_overrides_main_size" style="height: 100px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="flex_grow_shrink_at_most" style="height: 100px; width: 100px;">
<div>
<div style="flex-grow:1; flex-shrink:1;"></div>
</div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,38 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="wrap_column" style="height: 100px; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row" style="width: 100px; flex-direction: row; flex-wrap: wrap">
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_flex_end" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: flex-end;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
<div id="wrap_row_align_items_center" style="width: 100px; flex-direction: row; flex-wrap: wrap; align-items: center;">
<div style="height: 10px; width: 30px;"></div>
<div style="height: 20px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
<div style="height: 30px; width: 30px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutFlexWrapTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,70 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="justify_content_row_flex_start" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-start;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="justify_content_row_flex_end" style="width: 102px; height: 102px; flex-direction: row; justify-content: flex-end;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="justify_content_row_center" style="width: 102px; height: 102px; flex-direction: row; justify-content: center;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="justify_content_row_space_between" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-between;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="justify_content_row_space_around" style="width: 102px; height: 102px; flex-direction: row; justify-content: space-around;">
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
<div style="width: 10px;"></div>
</div>
<div id="justify_content_column_flex_start" style="width: 102px; height: 102px; justify-content: flex-start;">
<div style="height: 10px;"></div>
<div style="heigth: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="justify_content_column_flex_end" style="width: 102px; height: 102px; justify-content: flex-end;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="justify_content_column_center" style="width: 102px; height: 102px; justify-content: center;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="justify_content_column_space_between" style="width: 102px; height: 102px; justify-content: space-between;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
<div id="justify_content_column_space_around" style="width: 102px; height: 102px; justify-content: space-around;">
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
<div style="height: 10px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutJustifyContentTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,52 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="margin_start" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; margin-start: 10px;"></div>
</div>
<div id="margin_top" style="width: 100px; height: 100px;">
<div style="height: 10px; margin-top: 10px;"></div>
</div>
<div id="margin_end" style="width: 100px; height: 100px; flex-direction: row; justify-content: flex-end;">
<div style="width: 10px; margin-end: 10px;"></div>
</div>
<div id="margin_bottom" style="width: 100px; height: 100px; justify-content: flex-end;">
<div style="height: 10px; margin-bottom: 10px;"></div>
</div>
<div id="margin_and_flex_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_flex_column" style="width: 100px; height: 100px;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-top: 10px; margin-bottom; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_and_stretch_column" style="width: 100px; height: 100px;">
<div style="margin-start: 10px; margin-end; 10px; flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_row" style="width: 100px; height: 100px; flex-direction: row;">
<div style="margin-end; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="margin_with_sibling_column" style="width: 100px; height: 100px;">
<div style="margin-bottom; 10px; flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMarginTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,54 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="max_width" style="width: 100px; height: 100px;">
<div style="height: 10px; max-width: 50px;"></div>
</div>
<div id="max_height" style="width: 100px; height: 100px; flex-direction: row;">
<div style="width: 10px; max-height: 50px;"></div>
</div>
<div id="min_height" style="width: 100px; height: 100px;">
<div style="flex-grow: 1; min-height: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="min_width" style="width: 100px; height: 100px; flex-direction: row">
<div style="flex-grow: 1; min-width: 60px;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="justify_content_min_max" style="max-height: 200px; min-height: 100px; width: 100px; justify-content: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="align_items_min_max" style="max-width: 200px; min-width: 100px; height: 100px; align-items: center;">
<div style="width: 60px; height: 60px;"></div>
</div>
<div id="justify_content_overflow_min_max" style="min-height: 100px; max-height: 110px; justify-content: center;">
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
<div style="width: 50px; height: 50px;"></div>
</div>
<div id="flex_grow_within_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 100px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
<div id="flex_grow_within_constrained_max_width" style="width: 200px; height: 100px;">
<div style="flex-direction: row; max-width: 300px;">
<div style="height: 20px; flex-grow: 1;"></div>
</div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutMinMaxDimensionTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -7,29 +7,7 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/**
* @Generated by gentest/gentest.sh with the following input
*
<div id="padding_no_size" style="padding: 10px;">
</div>
<div id="padding_container_match_child" style="padding: 10px;">
<div style="width: 10px; height: 10px;"></div>
</div>
<div id="padding_flex_child" style="width: 100px; height: 100px; padding: 10px;">
<div style="width: 10px; flex-grow:1"></div>
</div>
<div id="padding_stretch_child" style="width: 100px; height: 100px; padding: 10px;">
<div style="height: 10px;"></div>
</div>
<div id="padding_center_child" style="width: 100px; height: 100px; padding-start: 10px; padding-top: 10; padding-end: 20px; padding-bottom: 20px; align-items: center; justify-content: center;">
<div style="height: 10px; width: 10px;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutPaddingTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>

View File

@@ -10,19 +10,9 @@
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>
class CSSLayoutRelayoutTest : public ::testing::Test {
TEST(CSSLayoutTest, dont_cache_computed_flex_basis_between_layouts) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
protected:
virtual void SetUp() {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, true);
}
virtual void TearDown() {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false);
}
};
TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) {
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
@@ -36,4 +26,6 @@ TEST_F(CSSLayoutRelayoutTest, dont_cache_computed_flex_basis_between_layouts) {
ASSERT_FLOAT_EQ(20, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureWebFlexBasis, false);
}

View File

@@ -0,0 +1,73 @@
/**
* Copyright (c) 2014-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*/
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>
static CSSSize _measureFloor(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize{
width = 10.2,
height = 10.2,
};
}
static CSSSize _measureCeil(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize{
width = 10.5,
height = 10.5,
};
}
TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_floor) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureFloor);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST(CSSLayoutTest, rounding_feature_with_custom_measure_func_ceil) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureCeil);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}

View File

@@ -7,67 +7,14 @@
* of patent rights can be found in the PATENTS file in the same directory.
*/
/*
*
<div id="pixel_rounding_flex_basis_flex_grow_row_width_of_100" style="width: 100px; height: 100px; flex-direction: row;">
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="pixel_rounding_flex_basis_flex_grow_row_prime_number_width" style="width: 113px; height: 100px; flex-direction: row;">
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
<div style="flex-grow: 1;"></div>
</div>
<div id="pixel_rounding_flex_basis_flex_shrink_row" style="width: 101px; height: 100px; flex-direction: row;">
<div style="flex-basis: 100px; flex-shrink: 1;"></div>
<div style="flex-basis: 25px;"></div>
<div style="flex-basis: 25px;"></div>
</div>
<div id="pixel_rounding_flex_basis_overrides_main_size" style="height: 113px; width: 100px;">
<div style="height: 20px; flex-grow:1; flex-basis:50px;"></div>
<div style="height: 10px; flex-grow:1;"></div>
<div style="height: 10px; flex-grow:1;"></div>
</div>
<div id="rounding_feature_total_fractial" style="height: 113.4px; width: 87.4px;">
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;"></div>
<div style="height: 10px; flex-grow:1.6;"></div>
<div style="height: 10.7px; flex-grow:1.1;"></div>
</div>
<div id="rounding_feature_total_fractial_nested" style="height: 113.4px; width: 87.4px;">
<div style="height: 20.3px; flex-grow:0.7; flex-basis:50.3px;">
<div style="bottom: 13.3px; height: 9.9px; flex-grow:1.2; flex-basis:0.3px;"></div>
<div style="top: 13.3px; height: 1.1px; flex-grow:4.2; flex-basis:0.3px;"></div>
</div>
<div style="height: 10px; flex-grow:1.6;"></div>
<div style="height: 10.7px; flex-grow:1.1;"></div>
</div>
*
*/
// @Generated by gentest/gentest.rb from gentest/fixtures/CSSLayoutRoundingTest.html
#include <CSSLayout/CSSLayout.h>
#include <gtest/gtest.h>
class CSSLayoutFeatureRoundingTest : public ::testing::Test {
TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_width_of_100) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
protected:
virtual void SetUp() {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
}
virtual void TearDown() {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
};
TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_width_of_100) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetWidth(root, 100);
@@ -129,9 +76,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_wid
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_prime_number_width) {
TEST(CSSLayoutTest, rounding_flex_basis_flex_grow_row_prime_number_width) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetWidth(root, 113);
@@ -221,9 +172,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_grow_row_pri
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child4));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_shrink_row) {
TEST(CSSLayoutTest, rounding_flex_basis_flex_shrink_row) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetFlexDirection(root, CSSFlexDirectionRow);
CSSNodeStyleSetWidth(root, 101);
@@ -286,10 +241,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_rounding_flex_basis_flex_shrink_row)
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST(CSSLayoutTest, rounding_flex_basis_overrides_main_size) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
TEST_F(CSSLayoutFeatureRoundingTest, pixel_roundingflex_basis_overrides_main_size) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 113);
@@ -311,52 +269,232 @@ TEST_F(CSSLayoutFeatureRoundingTest, pixel_roundingflex_basis_overrides_main_siz
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_EQ(64, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetHeight(root_child0));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_EQ(64, CSSNodeLayoutGetTop(root_child1));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(64, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child1));
ASSERT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(100, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_1) {
TEST(CSSLayoutTest, rounding_total_fractial) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 87.4f);
CSSNodeStyleSetHeight(root, 113.4f);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 0.7f);
CSSNodeStyleSetFlexBasis(root_child0, 50.3f);
CSSNodeStyleSetHeight(root_child0, 20.3f);
CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1.6f);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child2, 1.1f);
CSSNodeStyleSetHeight(root_child2, 10.7f);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST(CSSLayoutTest, rounding_total_fractial_nested) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 87.4f);
CSSNodeStyleSetHeight(root, 113.4f);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 0.7f);
CSSNodeStyleSetFlexBasis(root_child0, 50.3f);
CSSNodeStyleSetHeight(root_child0, 20.3f);
CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child0, 1);
CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f);
CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f);
CSSNodeStyleSetHeight(root_child0_child0, 9.9f);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
const CSSNodeRef root_child0_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child1, 4);
CSSNodeStyleSetFlexBasis(root_child0_child1, 0.3f);
CSSNodeStyleSetPosition(root_child0_child1, CSSEdgeTop, 13.3f);
CSSNodeStyleSetHeight(root_child0_child1, 1.1f);
CSSNodeInsertChild(root_child0, root_child0_child1, 1);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1.6f);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child2, 1.1f);
CSSNodeStyleSetHeight(root_child2, 10.7f);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(47, CSSNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(12, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(47, CSSNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST(CSSLayoutTest, rounding_fractial_input_1) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 113.4f);
@@ -421,9 +559,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_1) {
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_2) {
TEST(CSSLayoutTest, rounding_fractial_input_2) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 100);
CSSNodeStyleSetHeight(root, 113.6f);
@@ -488,9 +630,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_2) {
ASSERT_FLOAT_EQ(25, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_3) {
TEST(CSSLayoutTest, rounding_fractial_input_3) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.3f);
CSSNodeStyleSetWidth(root, 100);
@@ -556,9 +702,13 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_3) {
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}
TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_4) {
TEST(CSSLayoutTest, rounding_fractial_input_4) {
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, true);
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetPosition(root, CSSEdgeTop, 0.7f);
CSSNodeStyleSetWidth(root, 100);
@@ -624,229 +774,6 @@ TEST_F(CSSLayoutFeatureRoundingTest, flex_basis_overrides_main_size_4) {
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 87.4f);
CSSNodeStyleSetHeight(root, 113.4f);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 0.7f);
CSSNodeStyleSetFlexBasis(root_child0, 50.3f);
CSSNodeStyleSetHeight(root_child0, 20.3f);
CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1.6f);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child2, 1.1f);
CSSNodeStyleSetHeight(root_child2, 10.7f);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_total_fractial_nested) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeStyleSetWidth(root, 87.4f);
CSSNodeStyleSetHeight(root, 113.4f);
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0, 0.7f);
CSSNodeStyleSetFlexBasis(root_child0, 50.3f);
CSSNodeStyleSetHeight(root_child0, 20.3f);
CSSNodeInsertChild(root, root_child0, 0);
const CSSNodeRef root_child0_child0 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child0, 1.2f);
CSSNodeStyleSetFlexBasis(root_child0_child0, 0.3f);
CSSNodeStyleSetPosition(root_child0_child0, CSSEdgeBottom, 13.3f);
CSSNodeStyleSetHeight(root_child0_child0, 9.9f);
CSSNodeInsertChild(root_child0, root_child0_child0, 0);
const CSSNodeRef root_child0_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child0_child1, 4.2f);
CSSNodeStyleSetFlexBasis(root_child0_child1, 0.3f);
CSSNodeStyleSetPosition(root_child0_child1, CSSEdgeTop, 13.3f);
CSSNodeStyleSetHeight(root_child0_child1, 1.1f);
CSSNodeInsertChild(root_child0, root_child0_child1, 1);
const CSSNodeRef root_child1 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child1, 1.6f);
CSSNodeStyleSetHeight(root_child1, 10);
CSSNodeInsertChild(root, root_child1, 1);
const CSSNodeRef root_child2 = CSSNodeNew();
CSSNodeStyleSetFlexGrow(root_child2, 1.1f);
CSSNodeStyleSetHeight(root_child2, 10.7f);
CSSNodeInsertChild(root, root_child2, 2);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionRTL);
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root));
ASSERT_FLOAT_EQ(113, CSSNodeLayoutGetHeight(root));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetTop(root_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetHeight(root_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child0));
ASSERT_FLOAT_EQ(-13, CSSNodeLayoutGetTop(root_child0_child0));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child0));
ASSERT_FLOAT_EQ(13, CSSNodeLayoutGetHeight(root_child0_child0));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child0_child1));
ASSERT_FLOAT_EQ(27, CSSNodeLayoutGetTop(root_child0_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child0_child1));
ASSERT_FLOAT_EQ(45, CSSNodeLayoutGetHeight(root_child0_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child1));
ASSERT_FLOAT_EQ(59, CSSNodeLayoutGetTop(root_child1));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child1));
ASSERT_FLOAT_EQ(30, CSSNodeLayoutGetHeight(root_child1));
ASSERT_FLOAT_EQ(0, CSSNodeLayoutGetLeft(root_child2));
ASSERT_FLOAT_EQ(89, CSSNodeLayoutGetTop(root_child2));
ASSERT_FLOAT_EQ(87, CSSNodeLayoutGetWidth(root_child2));
ASSERT_FLOAT_EQ(24, CSSNodeLayoutGetHeight(root_child2));
CSSNodeFreeRecursive(root);
}
static CSSSize _measureFloor(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize{
width = 10.2,
height = 10.2,
};
}
static CSSSize _measureCeil(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize{
width = 10.5,
height = 10.5,
};
}
TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_floor) {
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureFloor);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(10, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
}
TEST_F(CSSLayoutFeatureRoundingTest, rounding_feature_with_custom_measure_func_ceil) {
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeSetMeasureFunc(root_child0, _measureCeil);
CSSNodeInsertChild(root, root_child0, 0);
CSSNodeCalculateLayout(root, CSSUndefined, CSSUndefined, CSSDirectionLTR);
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetWidth(root_child0));
ASSERT_FLOAT_EQ(11, CSSNodeLayoutGetHeight(root_child0));
CSSNodeFreeRecursive(root);
CSSLayoutSetExperimentalFeatureEnabled(CSSExperimentalFeatureRounding, false);
}