// Copyright 2019 The Chromium Authors // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #ifdef UNSAFE_BUFFERS_BUILD // TODO(crbug.com/354829279): Remove this and convert code to safer constructs. #pragma allow_unsafe_buffers #endif #include <tuple> #include "base/containers/contains.h" #include "base/strings/string_util.h" #include "base/strings/stringprintf.h" #include "base/test/task_environment.h" #include "build/build_config.h" #include "testing/gtest/include/gtest/gtest.h" #include "third_party/icu/source/common/unicode/uchar.h" #include "third_party/icu/source/common/unicode/uscript.h" #include "third_party/icu/source/common/unicode/utf16.h" #include "third_party/skia/include/core/SkTypeface.h" #include "ui/gfx/font_fallback_win.h" #include "ui/gfx/platform_font.h" #include "ui/gfx/test/font_fallback_test_data.h" namespace gfx { namespace { // Options to parameterized unittests. struct FallbackFontTestOption { … }; const FallbackFontTestOption default_fallback_option = …; // Options for tests that does not validate the GetFallbackFont(...) parameters. const FallbackFontTestOption untested_fallback_option = …; struct BaseFontTestOption { … }; constexpr BaseFontTestOption default_base_font; constexpr BaseFontTestOption styled_font = …; constexpr BaseFontTestOption sans_font = …; FallbackFontTestParamInfo; class GetFallbackFontTest : public ::testing::TestWithParam<FallbackFontTestParamInfo> { … }; } // namespace // This test ensures the font fallback work correctly. It will ensures that // 1) The script supports the text // 2) The input font does not already support the text // 3) The call to GetFallbackFont() succeed // 4) The fallback font has a glyph for every character of the text // // The previous checks can be activated or deactivated through the class // FallbackFontTestOption (e.g. test_option_). TEST_P(GetFallbackFontTest, GetFallbackFont) { … } // Produces a font test case for every script. std::vector<FallbackFontTestCase> GetSampleFontTestCases() { … } // Ensures that the default fallback font gives known results. The test // is validating that a known fallback font is given for a given text and font. INSTANTIATE_TEST_SUITE_P(…); // Ensures that font fallback functions are working properly for any string // (strings from any script). The test doesn't enforce the functions to // give a fallback font. The accepted behaviors are: // 1) The fallback function failed and doesn't provide a fallback. // 2) The fallback function succeeded and the font supports every glyphs. INSTANTIATE_TEST_SUITE_P(…); } // namespace gfx