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

Side by Side Diff: components/spellcheck/renderer/spellcheck_provider_hunspell_unittest.cc

Issue 2712833004: Stop SpellCheckProvider from deciding typing progress (Closed)
Patch Set: Add comment about partial word Created 3 years, 10 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 unified diff | Download patch
« no previous file with comments | « components/spellcheck/renderer/spellcheck_provider.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <vector> 5 #include <vector>
6 6
7 #include "base/stl_util.h" 7 #include "base/stl_util.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "components/spellcheck/common/spellcheck_marker.h" 9 #include "components/spellcheck/common/spellcheck_marker.h"
10 #include "components/spellcheck/renderer/spellcheck_provider_test.h" 10 #include "components/spellcheck/renderer/spellcheck_provider_test.h"
(...skipping 21 matching lines...) Expand all
32 // only a line being edited by the user. 32 // only a line being edited by the user.
33 TEST_F(SpellCheckProviderTest, MultiLineText) { 33 TEST_F(SpellCheckProviderTest, MultiLineText) {
34 FakeTextCheckingCompletion completion; 34 FakeTextCheckingCompletion completion;
35 35
36 // Verify that the SpellCheckProvider class does not spellcheck empty text. 36 // Verify that the SpellCheckProvider class does not spellcheck empty text.
37 provider_.ResetResult(); 37 provider_.ResetResult();
38 provider_.RequestTextChecking(base::string16(), &completion, 38 provider_.RequestTextChecking(base::string16(), &completion,
39 std::vector<SpellCheckMarker>()); 39 std::vector<SpellCheckMarker>());
40 EXPECT_TRUE(provider_.text_.empty()); 40 EXPECT_TRUE(provider_.text_.empty());
41 41
42 // Verify that the SpellCheckProvider class does not spellcheck text while we
43 // are typing a word.
44 provider_.ResetResult();
45 provider_.RequestTextChecking(ASCIIToUTF16("First"), &completion,
46 std::vector<SpellCheckMarker>());
47 EXPECT_TRUE(provider_.text_.empty());
48
49 // Verify that the SpellCheckProvider class spellcheck the first word when we 42 // Verify that the SpellCheckProvider class spellcheck the first word when we
50 // type a space key, i.e. when we finish typing a word. 43 // stop typing after finishing the first word.
51 provider_.ResetResult(); 44 provider_.ResetResult();
52 provider_.RequestTextChecking(ASCIIToUTF16("First "), &completion, 45 provider_.RequestTextChecking(ASCIIToUTF16("First"), &completion,
53 std::vector<SpellCheckMarker>()); 46 std::vector<SpellCheckMarker>());
54 EXPECT_EQ(ASCIIToUTF16("First "), provider_.text_); 47 EXPECT_EQ(ASCIIToUTF16("First"), provider_.text_);
55 48
56 // Verify that the SpellCheckProvider class spellcheck the first line when we 49 // Verify that the SpellCheckProvider class spellcheck the first line when we
57 // type a return key, i.e. when we finish typing a line. 50 // type a return key, i.e. when we finish typing a line.
58 provider_.ResetResult(); 51 provider_.ResetResult();
59 provider_.RequestTextChecking(ASCIIToUTF16("First Second\n"), &completion, 52 provider_.RequestTextChecking(ASCIIToUTF16("First Second\n"), &completion,
60 std::vector<SpellCheckMarker>()); 53 std::vector<SpellCheckMarker>());
61 EXPECT_EQ(ASCIIToUTF16("First Second\n"), provider_.text_); 54 EXPECT_EQ(ASCIIToUTF16("First Second\n"), provider_.text_);
62 55
63 // Verify that the SpellCheckProvider class spellcheck the lines when we 56 // Verify that the SpellCheckProvider class spellcheck the lines when we
64 // finish typing a word "Third" to the second line. 57 // finish typing a word "Third" to the second line.
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 std::vector<SpellCheckMarker>()); 128 std::vector<SpellCheckMarker>());
136 EXPECT_EQ(0U, completion.cancellation_count_) << "Should finish checking \"" 129 EXPECT_EQ(0U, completion.cancellation_count_) << "Should finish checking \""
137 << substring << "\""; 130 << substring << "\"";
138 131
139 provider_.RequestTextChecking(text, &completion, 132 provider_.RequestTextChecking(text, &completion,
140 std::vector<SpellCheckMarker>()); 133 std::vector<SpellCheckMarker>());
141 EXPECT_EQ(0U, completion.cancellation_count_) << "Should finish checking \"" 134 EXPECT_EQ(0U, completion.cancellation_count_) << "Should finish checking \""
142 << text << "\""; 135 << text << "\"";
143 } 136 }
144 137
145 // Tests that the SpellCheckProvider cancels spelling requests in the middle of
146 // a word.
147 TEST_F(SpellCheckProviderTest, CancelMidWordRequests) {
148 FakeTextCheckingCompletion completion;
149 provider_.RequestTextChecking(ASCIIToUTF16("hello "), &completion,
150 std::vector<SpellCheckMarker>());
151 EXPECT_EQ(completion.completion_count_, 1U);
152 EXPECT_EQ(completion.cancellation_count_, 0U);
153 EXPECT_EQ(provider_.spelling_service_call_count_, 1U);
154
155 provider_.RequestTextChecking(ASCIIToUTF16("hello world"), &completion,
156 std::vector<SpellCheckMarker>());
157 EXPECT_EQ(completion.completion_count_, 2U);
158 EXPECT_EQ(completion.cancellation_count_, 1U);
159 EXPECT_EQ(provider_.spelling_service_call_count_, 1U);
160
161 provider_.RequestTextChecking(ASCIIToUTF16("hello world."), &completion,
162 std::vector<SpellCheckMarker>());
163 EXPECT_EQ(completion.completion_count_, 3U);
164 EXPECT_EQ(completion.cancellation_count_, 1U);
165 EXPECT_EQ(provider_.spelling_service_call_count_, 2U);
166 }
167
168 } // namespace 138 } // namespace
OLDNEW
« no previous file with comments | « components/spellcheck/renderer/spellcheck_provider.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698