summaryrefslogtreecommitdiff
path: root/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc
diff options
context:
space:
mode:
Diffstat (limited to 'chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc')
-rw-r--r--chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc61
1 files changed, 61 insertions, 0 deletions
diff --git a/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc b/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc
index 9754276f0a8..1b505e57d1e 100644
--- a/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc
+++ b/chromium/third_party/blink/renderer/core/paint/inline_text_box_painter_test.cc
@@ -6,6 +6,7 @@
#include "testing/gmock/include/gmock/gmock.h"
#include "testing/gtest/include/gtest/gtest.h"
+#include "third_party/blink/renderer/core/editing/testing/selection_sample.h"
#include "third_party/blink/renderer/core/paint/paint_controller_paint_test.h"
using testing::ElementsAre;
@@ -27,4 +28,64 @@ TEST_P(InlineTextBoxPainterTest, LineBreak) {
EXPECT_EQ(6u, ContentDisplayItems().size());
}
+class InlineTextBoxPainterNonNGTest : public PaintControllerPaintTest,
+ public ScopedLayoutNGForTest {
+ public:
+ InlineTextBoxPainterNonNGTest() : ScopedLayoutNGForTest(false) {}
+};
+
+INSTANTIATE_PAINT_TEST_SUITE_P(InlineTextBoxPainterNonNGTest);
+
+TEST_P(InlineTextBoxPainterNonNGTest, RecordedSelectionAll) {
+ if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
+ return;
+ SetBodyInnerHTML("<span>A<br>B<br>C</span>");
+
+ GetDocument().GetFrame()->Selection().SetHandleVisibleForTesting();
+ GetDocument().GetFrame()->Selection().SelectAll();
+ UpdateAllLifecyclePhasesForTest();
+
+ auto chunks = ContentPaintChunks();
+ EXPECT_EQ(chunks.size(), 1u);
+ EXPECT_TRUE(chunks.begin()->layer_selection_data->start.has_value());
+ EXPECT_TRUE(chunks.begin()->layer_selection_data->end.has_value());
+ PaintedSelectionBound start =
+ chunks.begin()->layer_selection_data->start.value();
+ EXPECT_EQ(start.type, gfx::SelectionBound::LEFT);
+ EXPECT_EQ(start.edge_start, IntPoint(8, 8));
+ EXPECT_EQ(start.edge_end, IntPoint(8, 9));
+
+ PaintedSelectionBound end = chunks.begin()->layer_selection_data->end.value();
+ EXPECT_EQ(end.type, gfx::SelectionBound::RIGHT);
+ EXPECT_EQ(end.edge_start, IntPoint(9, 10));
+ EXPECT_EQ(end.edge_end, IntPoint(9, 11));
+}
+
+TEST_P(InlineTextBoxPainterNonNGTest, RecordedSelectionMultiline) {
+ if (!RuntimeEnabledFeatures::CompositeAfterPaintEnabled())
+ return;
+
+ GetDocument().GetFrame()->Selection().SetSelectionAndEndTyping(
+ SelectionSample::SetSelectionText(
+ GetDocument().body(),
+ "<div style='white-space:pre'>f^oo\nbar\nb|az</div>"));
+ GetDocument().GetFrame()->Selection().SetHandleVisibleForTesting();
+ UpdateAllLifecyclePhasesForTest();
+
+ auto chunks = ContentPaintChunks();
+ EXPECT_EQ(chunks.size(), 1u);
+ EXPECT_TRUE(chunks.begin()->layer_selection_data->start.has_value());
+ EXPECT_TRUE(chunks.begin()->layer_selection_data->end.has_value());
+ PaintedSelectionBound start =
+ chunks.begin()->layer_selection_data->start.value();
+ EXPECT_EQ(start.type, gfx::SelectionBound::LEFT);
+ EXPECT_EQ(start.edge_start, IntPoint(8, 8));
+ EXPECT_EQ(start.edge_end, IntPoint(8, 9));
+
+ PaintedSelectionBound end = chunks.begin()->layer_selection_data->end.value();
+ EXPECT_EQ(end.type, gfx::SelectionBound::RIGHT);
+ EXPECT_EQ(end.edge_start, IntPoint(9, 10));
+ EXPECT_EQ(end.edge_end, IntPoint(9, 11));
+}
+
} // namespace blink