Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1668)

Unified Diff: third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp

Issue 2960473002: [MarkersIntersectingRange #2.1] Add DocumentMarkerController::FirstMarkerIntersectingOffsetRange() (Closed)
Patch Set: Rebase Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp
index 52d9ddb57b8a77cf091b20e3979e5eadc74b753d..2d305c9039006b6e9b18aae27f6c044d373810ba 100644
--- a/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/markers/DocumentMarkerControllerTest.cpp
@@ -312,4 +312,45 @@ TEST_F(DocumentMarkerControllerTest, RemoveSpellingMarkersUnderWords) {
EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType());
}
+TEST_F(DocumentMarkerControllerTest, FirstMarkerIntersectingOffsetRange) {
+ SetBodyContent("<div contenteditable>123456789</div>");
+ GetDocument().UpdateStyleAndLayout();
+ Element* div = GetDocument().QuerySelector("div");
+ Text* text = ToText(div->firstChild());
+
+ // Add a spelling marker on "123"
+ MarkerController().AddSpellingMarker(
+ EphemeralRange(Position(text, 0), Position(text, 3)));
+
+ // Query for a spellcheck marker intersecting "3456"
+ const DocumentMarker* const result =
+ MarkerController().FirstMarkerIntersectingOffsetRange(
+ *text, 2, 6, DocumentMarker::MisspellingMarkers());
+
+ EXPECT_EQ(DocumentMarker::kSpelling, result->GetType());
+ EXPECT_EQ(0u, result->StartOffset());
+ EXPECT_EQ(3u, result->EndOffset());
+}
+
+TEST_F(DocumentMarkerControllerTest,
+ FirstMarkerIntersectingOffsetRange_collapsed) {
+ SetBodyContent("<div contenteditable>123456789</div>");
+ GetDocument().UpdateStyleAndLayout();
+ Element* div = GetDocument().QuerySelector("div");
+ Text* text = ToText(div->firstChild());
+
+ // Add a spelling marker on "123"
+ MarkerController().AddSpellingMarker(
+ EphemeralRange(Position(text, 0), Position(text, 3)));
+
+ // Query for a spellcheck marker containing the position between "1" and "2"
+ const DocumentMarker* const result =
+ MarkerController().FirstMarkerIntersectingOffsetRange(
+ *text, 1, 1, DocumentMarker::MisspellingMarkers());
+
+ EXPECT_EQ(DocumentMarker::kSpelling, result->GetType());
+ EXPECT_EQ(0u, result->StartOffset());
+ EXPECT_EQ(3u, result->EndOffset());
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/editing/markers/DocumentMarkerController.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698