chromium/third_party/blink/renderer/core/layout/layout_text_test.cc

// Copyright 2016 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/core/layout/layout_text.h"

#include <numeric>

#include "base/test/scoped_feature_list.h"
#include "build/build_config.h"
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/renderer/core/dom/pseudo_element.h"
#include "third_party/blink/renderer/core/editing/frame_selection.h"
#include "third_party/blink/renderer/core/editing/position_with_affinity.h"
#include "third_party/blink/renderer/core/editing/selection_template.h"
#include "third_party/blink/renderer/core/editing/testing/selection_sample.h"
#include "third_party/blink/renderer/core/layout/inline/inline_node_data.h"
#include "third_party/blink/renderer/core/testing/core_unit_test_helper.h"
#include "third_party/blink/renderer/platform/testing/font_test_helpers.h"

namespace blink {

ElementsAre;

namespace {

class LayoutTextTest : public RenderingTest {};

}  // namespace

#if BUILDFLAG(IS_WIN)
TEST_F(LayoutTextTest, PrewarmFamily) {
  test::ScopedTestFontPrewarmer prewarmer;
  SetBodyInnerHTML(R"HTML(
    <style>
    #container { font-family: testfont; }
    </style>
    <div id="container">text</div>
  )HTML");
  EXPECT_THAT(prewarmer.PrewarmedFamilyNames(), ElementsAre("testfont"));
  LayoutObject* container = GetLayoutObjectByElementId("container");
  EXPECT_TRUE(container->StyleRef()
                  .GetFont()
                  .GetFontDescription()
                  .Family()
                  .IsPrewarmed());
}

// Test `@font-face` fonts are NOT prewarmed.
TEST_F(LayoutTextTest, PrewarmFontFace) {
  test::ScopedTestFontPrewarmer prewarmer;
  SetBodyInnerHTML(R"HTML(
    <style>
    @font-face {
      font-family: testfont;
      src: local(Arial);
    }
    #container { font-family: testfont; }
    </style>
    <div id="container">text</div>
  )HTML");
  EXPECT_THAT(prewarmer.PrewarmedFamilyNames(), ElementsAre());
  LayoutObject* container = GetLayoutObjectByElementId("container");
  EXPECT_FALSE(container->StyleRef()
                   .GetFont()
                   .GetFontDescription()
                   .Family()
                   .IsPrewarmed());
}

TEST_F(LayoutTextTest, PrewarmGenericFamily) {
  test::ScopedTestFontPrewarmer prewarmer;
  SetBodyInnerHTML(R"HTML(
    <style>
    #container { font-family: serif; }
    </style>
    <div id="container">text</div>
  )HTML");
  // No prewarms because |GenericFontFamilySettings| is empty.
  EXPECT_THAT(prewarmer.PrewarmedFamilyNames(), ElementsAre());
  LayoutObject* container = GetLayoutObjectByElementId("container");
  EXPECT_TRUE(container->StyleRef()
                  .GetFont()
                  .GetFontDescription()
                  .Family()
                  .IsPrewarmed());
}
#endif

struct OffsetMappingTestData {} offset_mapping_test_data[] =;

std::ostream& operator<<(std::ostream& out, OffsetMappingTestData data) {}

class MapDOMOffsetToTextContentOffset
    : public LayoutTextTest,
      public testing::WithParamInterface<OffsetMappingTestData> {};

INSTANTIATE_TEST_SUITE_P();

TEST_P(MapDOMOffsetToTextContentOffset, Basic) {}

TEST_F(LayoutTextTest, CharacterAfterWhitespaceCollapsing) {}

TEST_F(LayoutTextTest, CaretMinMaxOffset) {}

TEST_F(LayoutTextTest, ResolvedTextLength) {}

TEST_F(LayoutTextTest, ContainsCaretOffset) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetInPre) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetInPreLine) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetWithTrailingSpace) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetWithTrailingSpace1) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetWithTrailingSpace2) {}

TEST_F(LayoutTextTest, ContainsCaretOffsetWithTrailingSpace3) {}

TEST_F(LayoutTextTest, GetTextBoxInfoWithCollapsedWhiteSpace) {}

TEST_F(LayoutTextTest, GetTextBoxInfoWithGeneratedContent) {}

// For http://crbug.com/985488
TEST_F(LayoutTextTest, GetTextBoxInfoWithHidden) {}

// For http://crbug.com/985488
TEST_F(LayoutTextTest, GetTextBoxInfoWithEllipsis) {}

// For http://crbug.com/1003413
TEST_F(LayoutTextTest, GetTextBoxInfoWithEllipsisForPseudoAfter) {}

// Test the specialized code path in |PlainText| for when |!GetNode()|.
TEST_F(LayoutTextTest, PlainTextInPseudo) {}

TEST_F(LayoutTextTest, IsBeforeAfterNonCollapsedCharacterNoLineWrap) {}

TEST_F(LayoutTextTest, IsBeforeAfterNonCollapsedLineWrapSpace) {}

TEST_F(LayoutTextTest, IsBeforeAfterNonCollapsedCharacterBR) {}

TEST_F(LayoutTextTest, AbsoluteQuads) {}

TEST_F(LayoutTextTest, AbsoluteQuadsVRL) {}

TEST_F(LayoutTextTest, PhysicalLinesBoundingBox) {}

TEST_F(LayoutTextTest, PhysicalLinesBoundingBoxTextCombine) {}

TEST_F(LayoutTextTest, PhysicalLinesBoundingBoxVerticalRL) {}

TEST_F(LayoutTextTest, WordBreakElement) {}

TEST_F(LayoutTextTest, LocalSelectionRect) {}

TEST_F(LayoutTextTest, LocalSelectionRectLineBreak) {}

TEST_F(LayoutTextTest, LocalSelectionRectLineBreakPre) {}

TEST_F(LayoutTextTest, LocalSelectionRectRTL) {}

TEST_F(LayoutTextTest, LocalSelectionRectVertical) {}

TEST_F(LayoutTextTest, LocalSelectionRectVerticalRTL) {}

TEST_F(LayoutTextTest, LocalSelectionRectLineHeight) {}

TEST_F(LayoutTextTest, LocalSelectionRectNegativeLeading) {}

TEST_F(LayoutTextTest, LocalSelectionRectLineHeightVertical) {}

TEST_F(LayoutTextTest, VisualRectInDocumentSVGTspan) {}

TEST_F(LayoutTextTest, VisualRectInDocumentSVGTspanTB) {}

TEST_F(LayoutTextTest, PositionForPointAtLeading) {}

// https://crbug.com/2654312
TEST_F(LayoutTextTest, FloatFirstLetterPlainText) {}

TEST_F(LayoutTextTest, SetTextWithOffsetAppendBidi) {}

TEST_F(LayoutTextTest, SetTextWithOffsetAppendControl) {}

TEST_F(LayoutTextTest, SetTextWithOffsetAppendCollapseWhiteSpace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetAppend) {}

// http://crbug.com/1213235
TEST_F(LayoutTextTest, SetTextWithOffsetAppendEmojiWithZWJ) {}

TEST_F(LayoutTextTest, SetTextWithOffsetDelete) {}

TEST_F(LayoutTextTest, SetTextWithOffsetDeleteCollapseWhiteSpace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetDeleteCollapseWhiteSpaceEnd) {}

// http://crbug.com/1253931
TEST_F(LayoutTextTest, SetTextWithOffsetCopyItemBefore) {}

// web_tests/external/wpt/editing/run/delete.html?993-993
// web_tests/external/wpt/editing/run/forwarddelete.html?1193-1193
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteNbspInPreWrap) {}

TEST_F(LayoutTextTest, SetTextWithOffsetDeleteRTL) {}

// http://crbug.com/1000685
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteRTL2) {}

// editing/deleting/delete_ws_fixup.html
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteThenNonCollapse) {}

// editing/deleting/delete_ws_fixup.html
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteThenNonCollapse2) {}

// http://crbug.com/1039143
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteWithBidiControl) {}

// http://crbug.com/1125262
TEST_F(LayoutTextTest, SetTextWithOffsetDeleteWithGeneratedBreakOpportunity) {}

// http://crbug.com/1123251
TEST_F(LayoutTextTest, SetTextWithOffsetEditingTextCollapsedSpace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetInsert) {}

TEST_F(LayoutTextTest, SetTextWithOffsetInsertAfterSpace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetInserBeforetSpace) {}

// https://crbug.com/1391668
TEST_F(LayoutTextTest, SetTextWithOffsetInsertSameCharacters) {}

TEST_F(LayoutTextTest, SetTextWithOffsetNoRelocation) {}

TEST_F(LayoutTextTest, SetTextWithOffsetPrepend) {}

TEST_F(LayoutTextTest, SetTextWithOffsetReplace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetReplaceCollapseWhiteSpace) {}

TEST_F(LayoutTextTest, SetTextWithOffsetReplaceToExtend) {}

TEST_F(LayoutTextTest, SetTextWithOffsetReplaceToShrink) {}

TEST_F(LayoutTextTest, SetTextWithOffsetToEmpty) {}

}  // namespace blink