diff --git a/ReactCommon/fabric/attributedstring/BUCK b/ReactCommon/fabric/attributedstring/BUCK index 27e0692e7b3..e767d40ee9d 100644 --- a/ReactCommon/fabric/attributedstring/BUCK +++ b/ReactCommon/fabric/attributedstring/BUCK @@ -73,7 +73,7 @@ fb_xplat_cxx_test( "-Wall", ], contacts = ["oncall+react_native@xmail.facebook.com"], - platforms = APPLE, + platforms = (ANDROID, APPLE), deps = [ "xplat//folly:molly", "xplat//third-party/gmock:gtest", diff --git a/ReactCommon/fabric/attributedstring/conversions.h b/ReactCommon/fabric/attributedstring/conversions.h index e864eb6f057..c19a70d7ffc 100644 --- a/ReactCommon/fabric/attributedstring/conversions.h +++ b/ReactCommon/fabric/attributedstring/conversions.h @@ -7,6 +7,7 @@ #pragma once +#include #include #include #include @@ -188,5 +189,15 @@ inline std::string toString(const TextDecorationLinePattern &textDecorationLineP } } +inline folly::dynamic toDynamic(const ParagraphAttributes ¶graphAttributes) { + auto values = folly::dynamic::object(); + values("maximumNumberOfLines", paragraphAttributes.maximumNumberOfLines); + values("ellipsizeMode", toString(paragraphAttributes.ellipsizeMode)); + values("adjustsFontSizeToFit", paragraphAttributes.adjustsFontSizeToFit); + values("minimumFontSize", paragraphAttributes.minimumFontSize); + values("maximumFontSize", paragraphAttributes.maximumFontSize); + return values; +} + } // namespace react } // namespace facebook diff --git a/ReactCommon/fabric/attributedstring/tests/ParagraphAttributesTest.cpp b/ReactCommon/fabric/attributedstring/tests/ParagraphAttributesTest.cpp new file mode 100644 index 00000000000..162ca8a2aee --- /dev/null +++ b/ReactCommon/fabric/attributedstring/tests/ParagraphAttributesTest.cpp @@ -0,0 +1,37 @@ +/** + * 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 + +#include +#include +#include +#include +#include + +namespace facebook { +namespace react { + + +TEST(ParagraphAttributesTest, testToDynamic) { + auto paragraphAttributes = ParagraphAttributes(); + paragraphAttributes.maximumNumberOfLines = 2; + paragraphAttributes.adjustsFontSizeToFit = false; + paragraphAttributes.ellipsizeMode = EllipsizeMode::Middle; + paragraphAttributes.minimumFontSize = 10; + paragraphAttributes.maximumFontSize = 20; + + auto result = toDynamic(paragraphAttributes); + assert(result["maximumNumberOfLines"] == paragraphAttributes.maximumNumberOfLines); + assert(result["adjustsFontSizeToFit"] == paragraphAttributes.adjustsFontSizeToFit); + assert(result["ellipsizeMode"] == toString(paragraphAttributes.ellipsizeMode)); + assert(result["minimumFontSize"] == paragraphAttributes.minimumFontSize); + assert(result["maximumFontSize"] == paragraphAttributes.maximumFontSize); +} + +} +} diff --git a/ReactCommon/fabric/core/shadownode/LocalData.h b/ReactCommon/fabric/core/shadownode/LocalData.h index 2463f73bb14..baccf1cc22f 100644 --- a/ReactCommon/fabric/core/shadownode/LocalData.h +++ b/ReactCommon/fabric/core/shadownode/LocalData.h @@ -29,7 +29,6 @@ class LocalData: public Sealable, public DebugStringConvertible { - // Nothing. }; } // namespace react