diff --git a/ReactCommon/react/renderer/attributedstring/BUCK b/ReactCommon/react/renderer/attributedstring/BUCK index 9ab399565e0..7405ecddb60 100644 --- a/ReactCommon/react/renderer/attributedstring/BUCK +++ b/ReactCommon/react/renderer/attributedstring/BUCK @@ -74,6 +74,7 @@ fb_xplat_cxx_test( "-Wall", ], contacts = ["oncall+react_native@xmail.facebook.com"], + fbandroid_use_instrumentation_test = True, platforms = (ANDROID, APPLE, CXX), deps = [ ":attributedstring", diff --git a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp index 9e84969713d..f0dff668592 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/AttributedStringTest.cpp @@ -5,9 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -#include - -#include #include #include #include @@ -20,28 +17,28 @@ namespace react { #ifdef ANDROID TEST(AttributedStringTest, testToDynamic) { - auto attString = new AttributedString(); - auto fragment = new AttributedString::Fragment(); - fragment->string = "test"; + auto attributedString = AttributedString{}; + auto fragment = AttributedString::Fragment{}; + fragment.string = "test"; - auto text = new TextAttributes(); - text->foregroundColor = { + auto text = TextAttributes{}; + text.foregroundColor = { colorFromComponents({100 / 255.0, 153 / 255.0, 200 / 255.0, 1.0})}; - text->opacity = 0.5; - text->fontStyle = FontStyle::Italic; - text->fontWeight = FontWeight::Thin; - text->fontVariant = FontVariant::TabularNums; - fragment->textAttributes = *text; + text.opacity = 0.5; + text.fontStyle = FontStyle::Italic; + text.fontWeight = FontWeight::Thin; + text.fontVariant = FontVariant::TabularNums; + fragment.textAttributes = text; - attString->prependFragment(*fragment); + attributedString.appendFragment(fragment); - auto result = toDynamic(*attString); - assert(result["string"] == fragment->string); + auto result = toDynamic(attributedString); + EXPECT_EQ(result["string"], fragment.string); auto textAttribute = result["fragments"][0]["textAttributes"]; - assert(textAttribute["foregroundColor"] == toDynamic(text->foregroundColor)); - assert(textAttribute["opacity"] == text->opacity); - assert(textAttribute["fontStyle"] == toString(*text->fontStyle)); - assert(textAttribute["fontWeight"] == toString(*text->fontWeight)); + EXPECT_EQ(textAttribute["foregroundColor"], toDynamic(text.foregroundColor)); + EXPECT_EQ(textAttribute["opacity"], text.opacity); + EXPECT_EQ(textAttribute["fontStyle"], toString(text.fontStyle.value())); + EXPECT_EQ(textAttribute["fontWeight"], toString(text.fontWeight.value())); } #endif diff --git a/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp index 56378937062..8b44e8b9fc2 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/ParagraphAttributesTest.cpp @@ -5,9 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -#include - -#include #include #include #include @@ -19,20 +16,18 @@ namespace react { #ifdef ANDROID TEST(ParagraphAttributesTest, testToDynamic) { - auto paragraphAttributes = ParagraphAttributes(); + auto paragraphAttributes = ParagraphAttributes{}; paragraphAttributes.maximumNumberOfLines = 2; paragraphAttributes.adjustsFontSizeToFit = false; paragraphAttributes.ellipsizeMode = EllipsizeMode::Middle; auto result = toDynamic(paragraphAttributes); - assert( - result["maximumNumberOfLines"] == - paragraphAttributes.maximumNumberOfLines); - assert( - result["adjustsFontSizeToFit"] == - paragraphAttributes.adjustsFontSizeToFit); - assert( - result["ellipsizeMode"] == toString(paragraphAttributes.ellipsizeMode)); + EXPECT_EQ( + result["maximumNumberOfLines"], paragraphAttributes.maximumNumberOfLines); + EXPECT_EQ( + result["adjustsFontSizeToFit"], paragraphAttributes.adjustsFontSizeToFit); + EXPECT_EQ( + result["ellipsizeMode"], toString(paragraphAttributes.ellipsizeMode)); } #endif diff --git a/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp b/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp index 7c25e0c7278..7fce2b9a783 100644 --- a/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp +++ b/ReactCommon/react/renderer/attributedstring/tests/TextAttributesTest.cpp @@ -5,9 +5,6 @@ * LICENSE file in the root directory of this source tree. */ -#include - -#include #include #include #include @@ -20,19 +17,20 @@ namespace react { #ifdef ANDROID TEST(TextAttributesTest, testToDynamic) { - auto text = TextAttributes(); - text.foregroundColor = { + auto textAttributes = TextAttributes{}; + textAttributes.foregroundColor = { colorFromComponents({200 / 255.0, 153 / 255.0, 100 / 255.0, 1.0})}; - text.opacity = 0.5; - text.fontStyle = FontStyle::Italic; - text.fontWeight = FontWeight::Thin; - text.fontVariant = FontVariant::TabularNums; + textAttributes.opacity = 0.5; + textAttributes.fontStyle = FontStyle::Italic; + textAttributes.fontWeight = FontWeight::Thin; + textAttributes.fontVariant = FontVariant::TabularNums; - auto result = toDynamic(text); - assert(result["foregroundColor"] == toDynamic(text.foregroundColor)); - assert(result["opacity"] == text.opacity); - assert(result["fontStyle"] == toString(*text.fontStyle)); - assert(result["fontWeight"] == toString(*text.fontWeight)); + auto result = toDynamic(textAttributes); + EXPECT_EQ( + result["foregroundColor"], toDynamic(textAttributes.foregroundColor)); + EXPECT_EQ(result["opacity"], textAttributes.opacity); + EXPECT_EQ(result["fontStyle"], toString(textAttributes.fontStyle.value())); + EXPECT_EQ(result["fontWeight"], toString(textAttributes.fontWeight.value())); } #endif