Summary: `/*` is the standard throughout open source code. For example, Firefox uses single /*: https://hg.mozilla.org/mozilla-central/file/21d22b2f541258d3d1cf96c7ba5ad73e96e616b5/gfx/ipc/CompositorWidgetVsyncObserver.cpp#l3 In addition, Rust considers `/**` to be a doc comment (similar to Javadoc) and having such a comment at the beginning of the file causes `rustc` to barf. Note that some JavaScript tooling requires `/**`. This is OK since JavaScript files were not covered by the linter in the first place, but it would be good to have that tooling fixed too. Reviewed By: zertosh Differential Revision: D15640366 fbshipit-source-id: b4ed4599071516364d6109720750d6a43304c089
62 lines
2.3 KiB
C++
62 lines
2.3 KiB
C++
/*
|
|
* Copyright (c) Facebook, Inc. and its affiliates.
|
|
*
|
|
* This source code is licensed under the MIT license found in the LICENSE
|
|
* file in the root directory of this source tree.
|
|
*/
|
|
#include <gtest/gtest.h>
|
|
#include <yoga/YGNode.h>
|
|
#include <yoga/Yoga.h>
|
|
|
|
static float _baseline(YGNodeRef node, const float width, const float height) {
|
|
float* baseline = (float*) node->getContext();
|
|
return *baseline;
|
|
}
|
|
|
|
TEST(YogaTest, align_baseline_customer_func) {
|
|
const YGNodeRef root = YGNodeNew();
|
|
YGNodeStyleSetFlexDirection(root, YGFlexDirectionRow);
|
|
YGNodeStyleSetAlignItems(root, YGAlignBaseline);
|
|
YGNodeStyleSetWidth(root, 100);
|
|
YGNodeStyleSetHeight(root, 100);
|
|
|
|
const YGNodeRef root_child0 = YGNodeNew();
|
|
YGNodeStyleSetWidth(root_child0, 50);
|
|
YGNodeStyleSetHeight(root_child0, 50);
|
|
YGNodeInsertChild(root, root_child0, 0);
|
|
|
|
const YGNodeRef root_child1 = YGNodeNew();
|
|
YGNodeStyleSetWidth(root_child1, 50);
|
|
YGNodeStyleSetHeight(root_child1, 20);
|
|
YGNodeInsertChild(root, root_child1, 1);
|
|
|
|
float baselineValue = 10;
|
|
const YGNodeRef root_child1_child0 = YGNodeNew();
|
|
root_child1_child0->setContext(&baselineValue);
|
|
YGNodeStyleSetWidth(root_child1_child0, 50);
|
|
root_child1_child0->setBaselineFunc(_baseline);
|
|
YGNodeStyleSetHeight(root_child1_child0, 20);
|
|
YGNodeInsertChild(root_child1, root_child1_child0, 0);
|
|
YGNodeCalculateLayout(root, YGUndefined, YGUndefined, YGDirectionLTR);
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root));
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root));
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetWidth(root));
|
|
ASSERT_FLOAT_EQ(100, YGNodeLayoutGetHeight(root));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child0));
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child0));
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child0));
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetHeight(root_child0));
|
|
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetLeft(root_child1));
|
|
ASSERT_FLOAT_EQ(40, YGNodeLayoutGetTop(root_child1));
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1));
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1));
|
|
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetLeft(root_child1_child0));
|
|
ASSERT_FLOAT_EQ(0, YGNodeLayoutGetTop(root_child1_child0));
|
|
ASSERT_FLOAT_EQ(50, YGNodeLayoutGetWidth(root_child1_child0));
|
|
ASSERT_FLOAT_EQ(20, YGNodeLayoutGetHeight(root_child1_child0));
|
|
}
|