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

Side by Side Diff: chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc

Issue 1300213002: Offers suggestions for each language that marks a word misspelled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@multi-spellcheck
Patch Set: Fixed final nits. Created 5 years, 4 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 | « chrome/renderer/spellchecker/spellcheck.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 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 "chrome/renderer/spellchecker/spellcheck_provider_test.h" 5 #include "chrome/renderer/spellchecker/spellcheck_provider_test.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/path_service.h" 9 #include "base/path_service.h"
10 #include "base/strings/string_split.h" 10 #include "base/strings/string_split.h"
(...skipping 185 matching lines...) Expand 10 before | Expand all | Expand 10 after
196 TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckParagraph) { 196 TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckParagraph) {
197 ReinitializeSpellCheck("en-US,es-ES"); 197 ReinitializeSpellCheck("en-US,es-ES");
198 std::vector<SpellCheckResult> expected; 198 std::vector<SpellCheckResult> expected;
199 expected.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 7, 15)); 199 expected.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 7, 15));
200 expected.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 33, 7)); 200 expected.push_back(SpellCheckResult(SpellCheckResult::SPELLING, 33, 7));
201 201
202 ExpectSpellCheckParagraphResults( 202 ExpectSpellCheckParagraphResults(
203 // English, German, Spanish, and a misspelled word. 203 // English, German, Spanish, and a misspelled word.
204 base::UTF8ToUTF16("rocket Schwarzkommando destruyan pcnyhon"), expected); 204 base::UTF8ToUTF16("rocket Schwarzkommando destruyan pcnyhon"), expected);
205 } 205 }
206
207 // Ensure that suggestions are handled properly for multiple languages.
208 TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckSuggestions) {
209 ReinitializeSpellCheck("en-US,es-ES");
210 static const struct {
211 // A string of text for checking.
212 const wchar_t* input;
213 // The position and the length of the first invalid word.
214 int expected_misspelling_start;
215 int expected_misspelling_length;
216 // A comma separated string of suggested words that should occur, in their
217 // expected order.
218 const wchar_t* expected_suggestions;
219 } kTestCases[] = {
220 {L"rocket", 0, 0},
221 {L"destruyan", 0, 0},
222 {L"rocet", 0, 5, L"rocket,roce,crochet,troce,rocen"},
223 {L"jum", 0, 3, L"hum,jun,ju,um,juma"},
224 {L"asdne", 0, 5, L"sadness,desasne"},
225 };
226
227 for (size_t i = 0; i < arraysize(kTestCases); ++i) {
228 blink::WebVector<blink::WebString> suggestions;
229 int misspelling_start;
230 int misspelling_length;
231 static_cast<blink::WebSpellCheckClient*>(provider())
232 ->spellCheck(blink::WebString(base::WideToUTF16(kTestCases[i].input)),
233 misspelling_start, misspelling_length, &suggestions);
234
235 EXPECT_EQ(kTestCases[i].expected_misspelling_start, misspelling_start);
236 EXPECT_EQ(kTestCases[i].expected_misspelling_length, misspelling_length);
237 if (!kTestCases[i].expected_suggestions) {
238 EXPECT_EQ(0UL, suggestions.size());
239 continue;
240 }
241
242 std::vector<base::string16> expected_suggestions = base::SplitString(
243 base::WideToUTF16(kTestCases[i].expected_suggestions),
244 base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
245
246 EXPECT_EQ(expected_suggestions.size(), suggestions.size());
247 for (size_t j = 0;
248 j < std::min(expected_suggestions.size(), suggestions.size()); j++) {
249 EXPECT_EQ(expected_suggestions[j], base::string16(suggestions[j]));
250 }
251 }
252 }
OLDNEW
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698