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