Add utils to disable on mac/windows, disable invalid LibLxt tests on mac (#13189)

This commit is contained in:
Gary Qian 2019-10-16 16:43:31 -07:00 committed by GitHub
parent a1796fc0e9
commit ee1a140fa9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 112 additions and 13 deletions

View File

@ -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
----------------------------------------------------------------------------------------------------

View File

@ -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",
]

View File

@ -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);

41
third_party/txt/src/utils/LinuxUtils.h vendored Normal file
View File

@ -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

40
third_party/txt/src/utils/MacUtils.h vendored Normal file
View File

@ -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

View File

@ -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 <BaseTsd.h>
#include <intrin.h>
@ -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

View File

@ -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);

View File

@ -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)