Summary: @public Instead of silently ignorning non-leaf nodes with measure functions, we should assert that we don't create those kinds of trees. Reviewed By: emilsjolander Differential Revision: D4130770 fbshipit-source-id: a3ef10a2e63bbc12b5aa07977e4b84c8d59e3ffe
39 lines
1.2 KiB
C++
39 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>
|
|
|
|
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.*");
|
|
}
|