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

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

Issue 2948133004: [MarkersIntersectingRange #2] Add DocumentMarkerController::MarkersIntersectingRange() (Closed)
Patch Set: Created 3 years, 6 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 unified diff | Download patch
OLDNEW
1 /* 1 /*
2 * Copyright (c) 2013, Google Inc. All rights reserved. 2 * Copyright (c) 2013, Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after
322 MarkerController().RemoveSpellingMarkersUnderWords({"foo"}); 322 MarkerController().RemoveSpellingMarkersUnderWords({"foo"});
323 323
324 // RemoveSpellingMarkersUnderWords does not remove text match marker. 324 // RemoveSpellingMarkersUnderWords does not remove text match marker.
325 ASSERT_EQ(1u, MarkerController().Markers().size()); 325 ASSERT_EQ(1u, MarkerController().Markers().size());
326 const DocumentMarker& marker = *MarkerController().Markers()[0]; 326 const DocumentMarker& marker = *MarkerController().Markers()[0];
327 EXPECT_EQ(0u, marker.StartOffset()); 327 EXPECT_EQ(0u, marker.StartOffset());
328 EXPECT_EQ(3u, marker.EndOffset()); 328 EXPECT_EQ(3u, marker.EndOffset());
329 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType()); 329 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType());
330 } 330 }
331 331
332 TEST_F(DocumentMarkerControllerTest, MarkersIntersectingRange) {
333 SetBodyInnerHTML("<div contenteditable>123456789</div>");
334 GetDocument().UpdateStyleAndLayout();
335 Element* div = GetDocument().QuerySelector("div");
336 Node* text = div->firstChild();
337
338 // Add a spelling marker on "123"
339 MarkerController().AddSpellingMarker(
340 EphemeralRange(Position(text, 0), Position(text, 3)));
341 // Add a grammar marker on "456"
Xiaocheng 2017/06/22 03:25:10 s/grammar/text match/
342 MarkerController().AddTextMatchMarker(
343 EphemeralRange(Position(text, 3), Position(text, 6)),
344 TextMatchMarker::MatchStatus::kInactive);
345 // Add a grammar marker on "789"
346 MarkerController().AddSpellingMarker(
347 EphemeralRange(Position(text, 6), Position(text, 9)));
348
349 // Query for spellcheck markers intersecting "3456". The text match marker
350 // should not be returned, nor should the spelling marker touching the range.
351 const Vector<std::pair<Node*, DocumentMarker*>>& results =
352 MarkerController().MarkersIntersectingRange(
353 EphemeralRange(Position(text, 2), Position(text, 6)),
354 DocumentMarker::MisspellingMarkers());
355
356 EXPECT_EQ(1u, results.size());
357 EXPECT_EQ(DocumentMarker::kSpelling, results[0].second->GetType());
358 EXPECT_EQ(0u, results[0].second->StartOffset());
359 EXPECT_EQ(3u, results[0].second->EndOffset());
360 }
361
332 } // namespace blink 362 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698