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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/renderer/spellchecker/spellcheck.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc
diff --git a/chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc b/chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc
index 53873f4aecbe3a03022413fc7d75d2af31a82776..1da1d92ce14dd7ee17e7e82c70dba86614136f1f 100644
--- a/chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc
+++ b/chrome/renderer/spellchecker/spellcheck_multilingual_unittest.cc
@@ -203,3 +203,50 @@ TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckParagraph) {
// English, German, Spanish, and a misspelled word.
base::UTF8ToUTF16("rocket Schwarzkommando destruyan pcnyhon"), expected);
}
+
+// Ensure that suggestions are handled properly for multiple languages.
+TEST_F(MultilingualSpellCheckTest, MultilingualSpellCheckSuggestions) {
+ ReinitializeSpellCheck("en-US,es-ES");
+ static const struct {
+ // A string of text for checking.
+ const wchar_t* input;
+ // The position and the length of the first invalid word.
+ int expected_misspelling_start;
+ int expected_misspelling_length;
+ // A comma separated string of suggested words that should occur, in their
+ // expected order.
+ const wchar_t* expected_suggestions;
+ } kTestCases[] = {
+ {L"rocket", 0, 0},
+ {L"destruyan", 0, 0},
+ {L"rocet", 0, 5, L"rocket,roce,crochet,troce,rocen"},
+ {L"jum", 0, 3, L"hum,jun,ju,um,juma"},
+ {L"asdne", 0, 5, L"sadness,desasne"},
+ };
+
+ for (size_t i = 0; i < arraysize(kTestCases); ++i) {
+ blink::WebVector<blink::WebString> suggestions;
+ int misspelling_start;
+ int misspelling_length;
+ static_cast<blink::WebSpellCheckClient*>(provider())
+ ->spellCheck(blink::WebString(base::WideToUTF16(kTestCases[i].input)),
+ misspelling_start, misspelling_length, &suggestions);
+
+ EXPECT_EQ(kTestCases[i].expected_misspelling_start, misspelling_start);
+ EXPECT_EQ(kTestCases[i].expected_misspelling_length, misspelling_length);
+ if (!kTestCases[i].expected_suggestions) {
+ EXPECT_EQ(0UL, suggestions.size());
+ continue;
+ }
+
+ std::vector<base::string16> expected_suggestions = base::SplitString(
+ base::WideToUTF16(kTestCases[i].expected_suggestions),
+ base::string16(1, ','), base::TRIM_WHITESPACE, base::SPLIT_WANT_ALL);
+
+ EXPECT_EQ(expected_suggestions.size(), suggestions.size());
+ for (size_t j = 0;
+ j < std::min(expected_suggestions.size(), suggestions.size()); j++) {
+ EXPECT_EQ(expected_suggestions[j], base::string16(suggestions[j]));
+ }
+ }
+}
« 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