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

Unified Diff: third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp

Issue 2911253003: [Reland] Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Fix typo 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 side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp
diff --git a/third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp b/third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp
index 3e393d9debebb8b2f0359a5b99e6cb2aaf27f42e..e4539ef6109f23f32b8ce9ce1c6125f3ac3aedb0 100644
--- a/third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp
+++ b/third_party/WebKit/Source/core/editing/spellcheck/SpellCheckerTest.cpp
@@ -5,6 +5,8 @@
#include "core/editing/spellcheck/SpellChecker.h"
#include "core/editing/Editor.h"
+#include "core/editing/markers/DocumentMarkerController.h"
+#include "core/editing/spellcheck/SpellCheckRequester.h"
#include "core/editing/spellcheck/SpellCheckTestBase.h"
#include "core/frame/LocalFrame.h"
#include "core/frame/LocalFrameView.h"
@@ -82,4 +84,33 @@ TEST_F(SpellCheckerTest, SpellCheckDoesNotCauseUpdateLayout) {
EXPECT_EQ(start_count, LayoutCount());
}
+TEST_F(SpellCheckerTest, MarkAndReplaceForHandlesMultipleReplacements) {
+ SetBodyContent(
+ "<div contenteditable>"
+ "spllchck"
+ "</div>");
+ Element* div = GetDocument().QuerySelector("div");
+ Node* text = div->firstChild();
+ EphemeralRange range_to_check =
+ EphemeralRange(Position(text, 0), Position(text, 8));
+
+ SpellCheckRequest* request = SpellCheckRequest::Create(range_to_check, 0);
+
+ TextCheckingResult result;
+ result.decoration = TextDecorationType::kTextDecorationTypeSpelling;
+ result.location = 0;
+ result.length = 8;
+ result.replacements = Vector<String>({"spellcheck", "spillchuck"});
+
+ GetDocument().GetFrame()->GetSpellChecker().MarkAndReplaceFor(
+ request, Vector<TextCheckingResult>({result}));
+
+ ASSERT_EQ(1u, GetDocument().Markers().Markers().size());
+
+ // The Spelling marker's description should be a newline-separated list of the
+ // suggested replacements
+ EXPECT_EQ("spellcheck\nspillchuck",
+ GetDocument().Markers().Markers()[0]->Description());
+}
+
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698