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

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

Issue 2848943002: Allow storing multiple replacements on SpellCheckResult (Closed)
Patch Set: Rebase 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 d1ab143fc6f408b06fe77d36abd4f6e19aff174e..e1e4767b60d3a2c85ebe7163c1c8ff42f6d00a1e 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/FrameView.h"
#include "core/frame/LocalFrame.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