| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "core/editing/spellcheck/SpellChecker.h" | 5 #include "core/editing/spellcheck/SpellChecker.h" |
| 6 | 6 |
| 7 #include "core/editing/Editor.h" | 7 #include "core/editing/Editor.h" |
| 8 #include "core/editing/markers/DocumentMarkerController.h" | |
| 9 #include "core/editing/spellcheck/SpellCheckRequester.h" | |
| 10 #include "core/editing/spellcheck/SpellCheckTestBase.h" | 8 #include "core/editing/spellcheck/SpellCheckTestBase.h" |
| 11 #include "core/frame/LocalFrame.h" | 9 #include "core/frame/LocalFrame.h" |
| 12 #include "core/frame/LocalFrameView.h" | 10 #include "core/frame/LocalFrameView.h" |
| 13 #include "core/frame/Settings.h" | 11 #include "core/frame/Settings.h" |
| 14 #include "core/html/HTMLInputElement.h" | 12 #include "core/html/HTMLInputElement.h" |
| 15 | 13 |
| 16 namespace blink { | 14 namespace blink { |
| 17 | 15 |
| 18 class SpellCheckerTest : public SpellCheckTestBase { | 16 class SpellCheckerTest : public SpellCheckTestBase { |
| 19 protected: | 17 protected: |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 77 | 75 |
| 78 EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); | 76 EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); |
| 79 ForceLayout(); | 77 ForceLayout(); |
| 80 int start_count = LayoutCount(); | 78 int start_count = LayoutCount(); |
| 81 GetFrame().GetSpellChecker().RespondToChangedSelection( | 79 GetFrame().GetSpellChecker().RespondToChangedSelection( |
| 82 old_selection.Start(), | 80 old_selection.Start(), |
| 83 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); | 81 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); |
| 84 EXPECT_EQ(start_count, LayoutCount()); | 82 EXPECT_EQ(start_count, LayoutCount()); |
| 85 } | 83 } |
| 86 | 84 |
| 87 TEST_F(SpellCheckerTest, MarkAndReplaceForHandlesMultipleReplacements) { | |
| 88 SetBodyContent( | |
| 89 "<div contenteditable>" | |
| 90 "spllchck" | |
| 91 "</div>"); | |
| 92 Element* div = GetDocument().QuerySelector("div"); | |
| 93 Node* text = div->firstChild(); | |
| 94 EphemeralRange range_to_check = | |
| 95 EphemeralRange(Position(text, 0), Position(text, 8)); | |
| 96 | |
| 97 SpellCheckRequest* request = SpellCheckRequest::Create(range_to_check, 0); | |
| 98 | |
| 99 TextCheckingResult result; | |
| 100 result.decoration = TextDecorationType::kTextDecorationTypeSpelling; | |
| 101 result.location = 0; | |
| 102 result.length = 8; | |
| 103 result.replacements = Vector<String>({"spellcheck", "spillchuck"}); | |
| 104 | |
| 105 GetDocument().GetFrame()->GetSpellChecker().MarkAndReplaceFor( | |
| 106 request, Vector<TextCheckingResult>({result})); | |
| 107 | |
| 108 ASSERT_EQ(1u, GetDocument().Markers().Markers().size()); | |
| 109 | |
| 110 // The Spelling marker's description should be a newline-separated list of the | |
| 111 // suggested replacements | |
| 112 EXPECT_EQ("spellcheck\nspillchuck", | |
| 113 GetDocument().Markers().Markers()[0]->Description()); | |
| 114 } | |
| 115 | |
| 116 } // namespace blink | 85 } // namespace blink |
| OLD | NEW |