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" |
8 #include "core/editing/spellcheck/SpellCheckTestBase.h" | 10 #include "core/editing/spellcheck/SpellCheckTestBase.h" |
9 #include "core/frame/FrameView.h" | 11 #include "core/frame/FrameView.h" |
10 #include "core/frame/LocalFrame.h" | 12 #include "core/frame/LocalFrame.h" |
11 #include "core/frame/Settings.h" | 13 #include "core/frame/Settings.h" |
12 #include "core/html/HTMLInputElement.h" | 14 #include "core/html/HTMLInputElement.h" |
13 | 15 |
14 namespace blink { | 16 namespace blink { |
15 | 17 |
16 class SpellCheckerTest : public SpellCheckTestBase { | 18 class SpellCheckerTest : public SpellCheckTestBase { |
17 protected: | 19 protected: |
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
75 | 77 |
76 EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); | 78 EXPECT_TRUE(GetFrame().GetSpellChecker().IsSpellCheckingEnabled()); |
77 ForceLayout(); | 79 ForceLayout(); |
78 int start_count = LayoutCount(); | 80 int start_count = LayoutCount(); |
79 GetFrame().GetSpellChecker().RespondToChangedSelection( | 81 GetFrame().GetSpellChecker().RespondToChangedSelection( |
80 old_selection.Start(), | 82 old_selection.Start(), |
81 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); | 83 FrameSelection::kCloseTyping | FrameSelection::kClearTypingStyle); |
82 EXPECT_EQ(start_count, LayoutCount()); | 84 EXPECT_EQ(start_count, LayoutCount()); |
83 } | 85 } |
84 | 86 |
| 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 |
85 } // namespace blink | 116 } // namespace blink |
OLD | NEW |