Files
yoga/tests/CSSLayoutMeasureTest.cpp
Jing Chen 502f3c7010 Reverted commit D4147298
Summary: If there is a single child which is flex grow and flex shrink then instead of measuring and then shrinking we can just set the flex basis to zero as we know the final result will be that the child take up all remaining space.

Reviewed By: gkassabli

Differential Revision: D4147298

fbshipit-source-id: 8416508a31e8d317bf59d956abdbe5760b55bb6d
2016-11-09 00:07:45 -08:00

41 lines
1.2 KiB
C++

/**
* 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>
#if GTEST_HAS_DEATH_TEST
static CSSSize _measure(CSSNodeRef node,
float width,
CSSMeasureMode widthMode,
float height,
CSSMeasureMode heightMode) {
return CSSSize {
.width = 0,
.height = 0,
};
}
TEST(CSSLayoutTest, cannot_add_child_to_node_with_measure_func) {
const CSSNodeRef root = CSSNodeNew();
CSSNodeSetMeasureFunc(root, _measure);
const CSSNodeRef root_child0 = CSSNodeNew();
ASSERT_DEATH(CSSNodeInsertChild(root, root_child0, 0), "Cannot add child.*");
}
TEST(CSSLayoutTest, cannot_add_measure_func_to_non_leaf_node) {
const CSSNodeRef root = CSSNodeNew();
const CSSNodeRef root_child0 = CSSNodeNew();
CSSNodeInsertChild(root, root_child0, 0);
ASSERT_DEATH(CSSNodeSetMeasureFunc(root, _measure), "Cannot set measure function.*");
}
#endif