chromium/third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face_test.cc

// Copyright 2024 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "third_party/blink/renderer/platform/fonts/shaping/harfbuzz_face.h"

#include "hb.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/platform/fonts/font.h"
#include "third_party/blink/renderer/platform/fonts/font_platform_data.h"
#include "third_party/blink/renderer/platform/fonts/glyph.h"
#include "third_party/blink/renderer/platform/fonts/shaping/variation_selector_mode.h"
#include "third_party/blink/renderer/platform/testing/font_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/runtime_enabled_features_test_helpers.h"
#include "third_party/blink/renderer/platform/testing/unit_test_helpers.h"
#include "third_party/googletest/src/googletest/include/gtest/gtest.h"

namespace blink {

namespace {

String WPTFontPath(const String& font_name) {}

hb_codepoint_t GetGlyphForVariationSequenceFromFont(
    Font font,
    UChar32 character,
    UChar32 variation_selector) {}

hb_codepoint_t GetGlyphForEmojiVSFromFontWithVS15(UChar32 character,
                                                  UChar32 variation_selector) {}

hb_codepoint_t GetGlyphForEmojiVSFromFontWithVS16(UChar32 character,
                                                  UChar32 variation_selector) {}

hb_codepoint_t GetGlyphForEmojiVSFromFontWithBaseCharOnly(
    UChar32 character,
    UChar32 variation_selector) {}

hb_codepoint_t GetGlyphForStandardizedVSFromFontWithBaseCharOnly() {}

hb_codepoint_t GetGlyphForCJKVSFromFontWithVS() {}

}  // namespace

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestFontWithVS) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestFontWithVS_IgnoreVS) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestFontWithVS_VSFlagOff) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestFontWithBaseCharOnly) {}

TEST(HarfBuzzFaceTest,
     HarfBuzzGetNominalGlyph_TestFontWithBaseCharOnly_IgnoreVS) {}

TEST(HarfBuzzFaceTest,
     HarfBuzzGetNominalGlyph_TestFontWithBaseCharOnly_VSFlagOff) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestFontWithoutBaseChar) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestVariantEmojiEmoji) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestVariantEmojiText) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestVariantEmojiUnicode) {}

TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestVSOverrideVariantEmoji) {}

// Test emoji variation selectors support in system fallback. We are only
// enabling this feature on Windows, Android and Mac platforms.
#if BUILDFLAG(IS_MAC) || BUILDFLAG(IS_ANDROID) || BUILDFLAG(IS_WIN)
TEST(HarfBuzzFaceTest, HarfBuzzGetNominalGlyph_TestSystemFallbackEmojiVS) {
  ScopedFontVariationSequencesForTest scoped_variation_sequences_feature(true);
  ScopedFontVariantEmojiForTest scoped_variant_emoji_feature(true);
  ScopedSystemFallbackEmojiVSSupportForTest scoped_system_emoji_vs_feature(
      true);

  HarfBuzzFace::SetVariationSelectorMode(kUseSpecifiedVariationSelector);
  HarfBuzzFace::SetIsSystemFallbackStage(true);

  UChar32 character = kShakingFaceEmoji;

  hb_codepoint_t glyph_from_font_with_vs15 = GetGlyphForEmojiVSFromFontWithVS15(
      character, kVariationSelector15Character);
  EXPECT_TRUE(glyph_from_font_with_vs15);
  EXPECT_NE(glyph_from_font_with_vs15, kUnmatchedVSGlyphId);

  hb_codepoint_t glyph_from_font_with_vs16 = GetGlyphForEmojiVSFromFontWithVS16(
      character, kVariationSelector16Character);
  EXPECT_TRUE(glyph_from_font_with_vs16);
  EXPECT_NE(glyph_from_font_with_vs16, kUnmatchedVSGlyphId);

  hb_codepoint_t glyph_from_font_without_vs =
      GetGlyphForEmojiVSFromFontWithBaseCharOnly(character, 0);
  EXPECT_TRUE(glyph_from_font_without_vs);
  EXPECT_NE(glyph_from_font_without_vs, kUnmatchedVSGlyphId);
}
#endif

}  // namespace blink