From ee1a140fa9cd17215967629ada7283968043f666 Mon Sep 17 00:00:00 2001 From: Gary Qian Date: Wed, 16 Oct 2019 16:43:31 -0700 Subject: [PATCH] Add utils to disable on mac/windows, disable invalid LibLxt tests on mac (#13189) --- ci/licenses_golden/licenses_flutter | 2 + third_party/txt/BUILD.gn | 2 + third_party/txt/src/txt/paragraph_txt.h | 8 ++-- third_party/txt/src/utils/LinuxUtils.h | 41 ++++++++++++++++++++ third_party/txt/src/utils/MacUtils.h | 40 +++++++++++++++++++ third_party/txt/src/utils/WindowsUtils.h | 9 +++++ third_party/txt/tests/paragraph_unittests.cc | 22 ++++++----- third_party/txt/tests/txt_test_utils.cc | 1 + 8 files changed, 112 insertions(+), 13 deletions(-) create mode 100644 third_party/txt/src/utils/LinuxUtils.h create mode 100644 third_party/txt/src/utils/MacUtils.h diff --git a/ci/licenses_golden/licenses_flutter b/ci/licenses_golden/licenses_flutter index fd655534cfa..b350d564d67 100644 --- a/ci/licenses_golden/licenses_flutter +++ b/ci/licenses_golden/licenses_flutter @@ -1216,7 +1216,9 @@ FILE: ../../../flutter/third_party/txt/src/txt/typeface_font_asset_provider.cc FILE: ../../../flutter/third_party/txt/src/txt/typeface_font_asset_provider.h FILE: ../../../flutter/third_party/txt/src/utils/JenkinsHash.cpp FILE: ../../../flutter/third_party/txt/src/utils/JenkinsHash.h +FILE: ../../../flutter/third_party/txt/src/utils/LinuxUtils.h FILE: ../../../flutter/third_party/txt/src/utils/LruCache.h +FILE: ../../../flutter/third_party/txt/src/utils/MacUtils.h FILE: ../../../flutter/third_party/txt/src/utils/TypeHelpers.h FILE: ../../../flutter/third_party/txt/src/utils/WindowsUtils.h ---------------------------------------------------------------------------------------------------- diff --git a/third_party/txt/BUILD.gn b/third_party/txt/BUILD.gn index f9f14c7bf10..93d90e45bf3 100644 --- a/third_party/txt/BUILD.gn +++ b/third_party/txt/BUILD.gn @@ -119,7 +119,9 @@ source_set("txt") { "src/txt/typeface_font_asset_provider.h", "src/utils/JenkinsHash.cpp", "src/utils/JenkinsHash.h", + "src/utils/LinuxUtils.h", "src/utils/LruCache.h", + "src/utils/MacUtils.h", "src/utils/TypeHelpers.h", "src/utils/WindowsUtils.h", ] diff --git a/third_party/txt/src/txt/paragraph_txt.h b/third_party/txt/src/txt/paragraph_txt.h index ec6228f408d..dac77b4ebb0 100644 --- a/third_party/txt/src/txt/paragraph_txt.h +++ b/third_party/txt/src/txt/paragraph_txt.h @@ -35,6 +35,8 @@ #include "third_party/googletest/googletest/include/gtest/gtest_prod.h" // nogncheck #include "third_party/skia/include/core/SkFontMetrics.h" #include "third_party/skia/include/core/SkRect.h" +#include "utils/LinuxUtils.h" +#include "utils/MacUtils.h" #include "utils/WindowsUtils.h" namespace txt { @@ -136,7 +138,7 @@ class ParagraphTxt : public Paragraph { FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, CenterAlignParagraph); FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, JustifyAlignParagraph); FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, JustifyRTL); - FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, JustifyRTLNewLine); + FRIEND_TEST_LINUX_ONLY(ParagraphTest, JustifyRTLNewLine); FRIEND_TEST(ParagraphTest, DecorationsParagraph); FRIEND_TEST(ParagraphTest, ItalicsParagraph); FRIEND_TEST(ParagraphTest, ChineseParagraph); @@ -145,8 +147,8 @@ class ParagraphTxt : public Paragraph { FRIEND_TEST(ParagraphTest, LongWordParagraph); FRIEND_TEST(ParagraphTest, KernScaleParagraph); FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, NewlineParagraph); - FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, EmojiParagraph); - FRIEND_TEST_WINDOWS_DISABLED(ParagraphTest, EmojiMultiLineRectsParagraph); + FRIEND_TEST_LINUX_ONLY(ParagraphTest, EmojiParagraph); + FRIEND_TEST_LINUX_ONLY(ParagraphTest, EmojiMultiLineRectsParagraph); FRIEND_TEST(ParagraphTest, HyphenBreakParagraph); FRIEND_TEST(ParagraphTest, RepeatLayoutParagraph); FRIEND_TEST(ParagraphTest, Ellipsize); diff --git a/third_party/txt/src/utils/LinuxUtils.h b/third_party/txt/src/utils/LinuxUtils.h new file mode 100644 index 00000000000..da3e7772c9a --- /dev/null +++ b/third_party/txt/src/utils/LinuxUtils.h @@ -0,0 +1,41 @@ +/* + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef LINUX_UTILS_H +#define LINUX_UTILS_H + +#if defined(__linux__) +#define DISABLE_TEST_LINUX(TEST_NAME) TEST_NAME +#define FRIEND_TEST_LINUX_DISABLED_EXPANDED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) +#define FRIEND_TEST_LINUX_DISABLED(SUITE, TEST_NAME) \ + FRIEND_TEST_LINUX_DISABLED_EXPANDED(SUITE, DISABLE_TEST_LINUX(TEST_NAME)) + +#define FRIEND_TEST_LINUX_ONLY(SUITE, TEST_NAME) FRIEND_TEST(SUITE, TEST_NAME) +#define LINUX_ONLY(TEST_NAME) TEST_NAME + +#else +#define DISABLE_TEST_LINUX(TEST_NAME) DISABLED_##TEST_NAME +#define FRIEND_TEST_LINUX_DISABLED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) + +#define LINUX_ONLY(TEST_NAME) DISABLED_##TEST_NAME +#define FRIEND_TEST_LINUX_ONLY_EXPANDED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) +#define FRIEND_TEST_LINUX_ONLY(SUITE, TEST_NAME) \ + FRIEND_TEST_LINUX_ONLY_EXPANDED(SUITE, DISABLE_TEST_LINUX(TEST_NAME)) +#endif // defined(__linux__) +#endif // LINUX_UTILS_H diff --git a/third_party/txt/src/utils/MacUtils.h b/third_party/txt/src/utils/MacUtils.h new file mode 100644 index 00000000000..a4be25142e9 --- /dev/null +++ b/third_party/txt/src/utils/MacUtils.h @@ -0,0 +1,40 @@ +/* + * Copyright 2017 Google Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +#ifndef MAC_UTILS_H +#define MAC_UTILS_H + +#if defined(__APPLE__) +#define DISABLE_TEST_MAC(TEST_NAME) DISABLED_##TEST_NAME +#define FRIEND_TEST_MAC_DISABLED_EXPANDED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) +#define FRIEND_TEST_MAC_DISABLED(SUITE, TEST_NAME) \ + FRIEND_TEST_MAC_DISABLED_EXPANDED(SUITE, DISABLE_TEST_MAC(TEST_NAME)) + +#define FRIEND_TEST_MAC_ONLY(SUITE, TEST_NAME) FRIEND_TEST(SUITE, TEST_NAME) +#define MAC_ONLY(TEST_NAME) TEST_NAME + +#else +#define DISABLE_TEST_MAC(TEST_NAME) TEST_NAME +#define FRIEND_TEST_MAC_DISABLED(SUITE, TEST_NAME) FRIEND_TEST(SUITE, TEST_NAME) + +#define MAC_ONLY(TEST_NAME) DISABLED_##TEST_NAME +#define FRIEND_TEST_MAC_ONLY_EXPANDED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) +#define FRIEND_TEST_MAC_ONLY(SUITE, TEST_NAME) \ + FRIEND_TEST_MAC_ONLY_EXPANDED(SUITE, DISABLE_TEST_MAC(TEST_NAME)) +#endif // defined(__APPLE__) +#endif // MAC_UTILS_H diff --git a/third_party/txt/src/utils/WindowsUtils.h b/third_party/txt/src/utils/WindowsUtils.h index d846b193c69..fc30637a6c9 100644 --- a/third_party/txt/src/utils/WindowsUtils.h +++ b/third_party/txt/src/utils/WindowsUtils.h @@ -24,6 +24,9 @@ #define FRIEND_TEST_WINDOWS_DISABLED(SUITE, TEST_NAME) \ FRIEND_TEST_WINDOWS_DISABLED_EXPANDED(SUITE, DISABLE_TEST_WINDOWS(TEST_NAME)) +#define FRIEND_TEST_WINDOWS_ONLY(SUITE, TEST_NAME) FRIEND_TEST(SUITE, TEST_NAME) +#define WINDOWS_ONLY(TEST_NAME) TEST_NAME + #define NOMINMAX #include #include @@ -55,5 +58,11 @@ typedef SSIZE_T ssize_t; #define DISABLE_TEST_WINDOWS(TEST_NAME) TEST_NAME #define FRIEND_TEST_WINDOWS_DISABLED(SUITE, TEST_NAME) \ FRIEND_TEST(SUITE, TEST_NAME) + +#define WINDOWS_ONLY(TEST_NAME) DISABLED_##TEST_NAME +#define FRIEND_TEST_WINDOWS_ONLY_EXPANDED(SUITE, TEST_NAME) \ + FRIEND_TEST(SUITE, TEST_NAME) +#define FRIEND_TEST_WINDOWS_ONLY(SUITE, TEST_NAME) \ + FRIEND_TEST_WINDOWS_ONLY_EXPANDED(SUITE, DISABLE_TEST_WINDOWS(TEST_NAME)) #endif // defined(_WIN32) #endif // WINDOWS_UTILS_H diff --git a/third_party/txt/tests/paragraph_unittests.cc b/third_party/txt/tests/paragraph_unittests.cc index afe70ef1a84..6409b530e69 100644 --- a/third_party/txt/tests/paragraph_unittests.cc +++ b/third_party/txt/tests/paragraph_unittests.cc @@ -29,6 +29,7 @@ #include "txt_test_utils.h" #define DISABLE_ON_WINDOWS(TEST) DISABLE_TEST_WINDOWS(TEST) +#define DISABLE_ON_MAC(TEST) DISABLE_TEST_MAC(TEST) namespace txt { @@ -269,7 +270,7 @@ TEST_F(ParagraphTest, LineMetricsParagraph1) { 1.0253906); } -TEST_F(ParagraphTest, LineMetricsParagraph2) { +TEST_F(ParagraphTest, DISABLE_ON_MAC(LineMetricsParagraph2)) { const char* text = "test string alphabetic"; auto icu_text = icu::UnicodeString::fromUTF8(text); std::u16string alphabetic(icu_text.getBuffer(), @@ -1010,7 +1011,8 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(InlinePlaceholderMiddleParagraph)) { } TEST_F(ParagraphTest, - DISABLE_ON_WINDOWS(InlinePlaceholderIdeographicBaselineParagraph)) { + DISABLE_ON_MAC( + DISABLE_ON_WINDOWS(InlinePlaceholderIdeographicBaselineParagraph))) { const char* text = "給能上目秘使"; auto icu_text = icu::UnicodeString::fromUTF8(text); std::u16string u16_text(icu_text.getBuffer(), @@ -2242,7 +2244,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(JustifyRTL)) { } } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(JustifyRTLNewLine)) { +TEST_F(ParagraphTest, LINUX_ONLY(JustifyRTLNewLine)) { const char* text = "אאא בּבּבּבּ אאאא\nבּבּ אאא בּבּבּ אאאאא בּבּבּבּ אאאא בּבּבּבּבּ " "אאאאא בּבּבּבּבּ אאאבּבּבּבּבּבּאאאאא בּבּבּבּבּבּאאאאאבּבּבּבּבּבּ אאאאא בּבּבּבּבּ " @@ -3139,7 +3141,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeParagraph)) { ASSERT_TRUE(Snapshot()); } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeTight)) { +TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeTight)) { const char* text = "( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)(" " ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)( ´・‿・`)(" @@ -3870,7 +3872,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeCenterParagraph)) { } TEST_F(ParagraphTest, - DISABLE_ON_WINDOWS(GetRectsForRangeCenterParagraphNewlineCentered)) { + LINUX_ONLY(GetRectsForRangeCenterParagraphNewlineCentered)) { const char* text = "01234\n"; auto icu_text = icu::UnicodeString::fromUTF8(text); std::u16string u16_text(icu_text.getBuffer(), @@ -4078,7 +4080,7 @@ TEST_F(ParagraphTest, ASSERT_TRUE(Snapshot()); } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(GetRectsForRangeStrut)) { +TEST_F(ParagraphTest, LINUX_ONLY(GetRectsForRangeStrut)) { const char* text = "Chinese 字典"; auto icu_text = icu::UnicodeString::fromUTF8(text); @@ -4499,7 +4501,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(NewlineParagraph)) { EXPECT_DOUBLE_EQ(paragraph->records_[5].offset().x(), 0); } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(EmojiParagraph)) { +TEST_F(ParagraphTest, LINUX_ONLY(EmojiParagraph)) { const char* text = "😀😃😄😁😆😅😂🤣☺😇🙂😍😡😟😢😻👽💩👍👎🙏👌👋👄👁👦👼👨‍🚀👨‍🚒🙋‍♂️👳👨‍👨‍👧‍👧\ 💼👡👠☂🐶🐰🐻🐼🐷🐒🐵🐔🐧🐦🐋🐟🐡🕸🐌🐴🐊🐄🐪🐘🌸🌏🔥🌟🌚🌝💦💧\ @@ -4543,7 +4545,7 @@ TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(EmojiParagraph)) { EXPECT_EQ(paragraph->records_[7].line(), 7ull); } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(EmojiMultiLineRectsParagraph)) { +TEST_F(ParagraphTest, LINUX_ONLY(EmojiMultiLineRectsParagraph)) { // clang-format off const char* text = "👩‍👩‍👦👩‍👩‍👧‍👧🇺🇸👩‍👩‍👦👩‍👩‍👧‍👧i🇺🇸👩‍👩‍👦👩‍👩‍👧‍👧🇺🇸👩‍👩‍👦👩‍👩‍👧‍👧🇺🇸" @@ -4990,7 +4992,7 @@ TEST_F(ParagraphTest, ComplexShadow) { ASSERT_TRUE(Snapshot()); } -TEST_F(ParagraphTest, BaselineParagraph) { +TEST_F(ParagraphTest, DISABLE_ON_MAC(BaselineParagraph)) { const char* text = "左線読設Byg後碁給能上目秘使約。満毎冠行来昼本可必図将発確年。今属場育" "図情闘陰野高備込制詩西校客。審対江置講今固残必託地集済決維駆年策。立得"; @@ -5133,7 +5135,7 @@ TEST_F(ParagraphTest, FontFallbackParagraph) { 0); } -TEST_F(ParagraphTest, DISABLE_ON_WINDOWS(StrutParagraph1)) { +TEST_F(ParagraphTest, LINUX_ONLY(StrutParagraph1)) { // The chinese extra height should be absorbed by the strut. const char* text = "01234満毎冠p来É本可\nabcd\n満毎É行p昼本可"; auto icu_text = icu::UnicodeString::fromUTF8(text); diff --git a/third_party/txt/tests/txt_test_utils.cc b/third_party/txt/tests/txt_test_utils.cc index 3dd8d4e940f..2382fd59e14 100644 --- a/third_party/txt/tests/txt_test_utils.cc +++ b/third_party/txt/tests/txt_test_utils.cc @@ -21,6 +21,7 @@ #include "third_party/skia/include/core/SkTypeface.h" #include "txt/asset_font_manager.h" #include "txt/typeface_font_asset_provider.h" +#include "utils/MacUtils.h" #include "utils/WindowsUtils.h" #if !defined(_WIN32)