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

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

Issue 2895253003: Split general DocumentMarkerController::AddMarker() method into spelling/grammar versions (Closed)
Patch Set: Split off InputMethodControllerTest changes, make other requested changes Created 3 years, 7 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 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
66 66
67 Text* DocumentMarkerControllerTest::CreateTextNode(const char* text_contents) { 67 Text* DocumentMarkerControllerTest::CreateTextNode(const char* text_contents) {
68 return GetDocument().createTextNode(String::FromUTF8(text_contents)); 68 return GetDocument().createTextNode(String::FromUTF8(text_contents));
69 } 69 }
70 70
71 void DocumentMarkerControllerTest::MarkNodeContents(Node* node) { 71 void DocumentMarkerControllerTest::MarkNodeContents(Node* node) {
72 // Force layoutObjects to be created; TextIterator, which is used in 72 // Force layoutObjects to be created; TextIterator, which is used in
73 // DocumentMarkerControllerTest::addMarker(), needs them. 73 // DocumentMarkerControllerTest::addMarker(), needs them.
74 GetDocument().UpdateStyleAndLayout(); 74 GetDocument().UpdateStyleAndLayout();
75 auto range = EphemeralRange::RangeOfContents(*node); 75 auto range = EphemeralRange::RangeOfContents(*node);
76 MarkerController().AddMarker(range.StartPosition(), range.EndPosition(), 76 MarkerController().AddSpellingMarker(range.StartPosition(),
77 DocumentMarker::kSpelling); 77 range.EndPosition());
78 } 78 }
79 79
80 void DocumentMarkerControllerTest::MarkNodeContentsTextMatch(Node* node) { 80 void DocumentMarkerControllerTest::MarkNodeContentsTextMatch(Node* node) {
81 // Force layoutObjects to be created; TextIterator, which is used in 81 // Force layoutObjects to be created; TextIterator, which is used in
82 // DocumentMarkerControllerTest::addMarker(), needs them. 82 // DocumentMarkerControllerTest::addMarker(), needs them.
83 GetDocument().UpdateStyleAndLayout(); 83 GetDocument().UpdateStyleAndLayout();
84 auto range = EphemeralRange::RangeOfContents(*node); 84 auto range = EphemeralRange::RangeOfContents(*node);
85 MarkerController().AddTextMatchMarker(range, 85 MarkerController().AddTextMatchMarker(range,
86 DocumentMarker::MatchStatus::kActive); 86 DocumentMarker::MatchStatus::kActive);
87 } 87 }
(...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after
308 } 308 }
309 309
310 TEST_F(DocumentMarkerControllerTest, RemoveSpellingMarkersUnderWords) { 310 TEST_F(DocumentMarkerControllerTest, RemoveSpellingMarkersUnderWords) {
311 SetBodyInnerHTML("<div contenteditable>foo</div>"); 311 SetBodyInnerHTML("<div contenteditable>foo</div>");
312 GetDocument().UpdateStyleAndLayout(); 312 GetDocument().UpdateStyleAndLayout();
313 Element* div = GetDocument().QuerySelector("div"); 313 Element* div = GetDocument().QuerySelector("div");
314 Node* text = div->firstChild(); 314 Node* text = div->firstChild();
315 315
316 // Add a spelling marker and a text match marker to "foo". 316 // Add a spelling marker and a text match marker to "foo".
317 const EphemeralRange marker_range(Position(text, 0), Position(text, 3)); 317 const EphemeralRange marker_range(Position(text, 0), Position(text, 3));
318 MarkerController().AddMarker(marker_range.StartPosition(), 318 MarkerController().AddSpellingMarker(marker_range.StartPosition(),
319 marker_range.EndPosition(), 319 marker_range.EndPosition());
320 DocumentMarker::kSpelling, "");
321 MarkerController().AddTextMatchMarker(marker_range, 320 MarkerController().AddTextMatchMarker(marker_range,
322 DocumentMarker::MatchStatus::kInactive); 321 DocumentMarker::MatchStatus::kInactive);
323 322
324 MarkerController().RemoveSpellingMarkersUnderWords({"foo"}); 323 MarkerController().RemoveSpellingMarkersUnderWords({"foo"});
325 324
326 // RemoveSpellingMarkersUnderWords does not remove text match marker. 325 // RemoveSpellingMarkersUnderWords does not remove text match marker.
327 ASSERT_EQ(1u, MarkerController().Markers().size()); 326 ASSERT_EQ(1u, MarkerController().Markers().size());
328 const DocumentMarker& marker = *MarkerController().Markers()[0]; 327 const DocumentMarker& marker = *MarkerController().Markers()[0];
329 EXPECT_EQ(0u, marker.StartOffset()); 328 EXPECT_EQ(0u, marker.StartOffset());
330 EXPECT_EQ(3u, marker.EndOffset()); 329 EXPECT_EQ(3u, marker.EndOffset());
331 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType()); 330 EXPECT_EQ(DocumentMarker::kTextMatch, marker.GetType());
332 } 331 }
333 332
334 } // namespace blink 333 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698