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

Unified Diff: chrome/renderer/spellchecker/spellcheck_unittest.cc

Issue 11299044: Unittest to go along with added no suggest flag. Currently tests no suggest for English dictionarie… (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 1 month 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/common/spellcheck_common.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_unittest.cc
===================================================================
--- chrome/renderer/spellchecker/spellcheck_unittest.cc (revision 167422)
+++ chrome/renderer/spellchecker/spellcheck_unittest.cc (working copy)
@@ -1141,4 +1141,65 @@
}
}
+// Checks that NOSUGGEST works in English dictionaries.
+TEST_F(SpellCheckTest, NoSuggest) {
+ static const struct {
+ const char* input;
+ bool should_pass;
+ } kTestCases[] = {
+ {"cocksucker", true},
+ {"cocksuckers", true},
+ };
+
+ static const char* kLocales[] = { "en-GB", "en-US", "en-CA", "en-AU" };
+
+ // First check that the NOSUGGEST flag didn't mark these words as not
+ // being in the dictionary.
+ size_t test_cases_size = ARRAYSIZE_UNSAFE(kTestCases);
+ for (size_t j = 0; j < arraysize(kLocales); ++j) {
+ ReinitializeSpellCheck(kLocales[j]);
+ for (size_t i = 0; i < test_cases_size; ++i) {
+ size_t input_length = 0;
+ if (kTestCases[i].input != NULL)
+ input_length = strlen(kTestCases[i].input);
+
+ int misspelling_start = 0;
+ int misspelling_length = 0;
+ bool result = spell_check()->SpellCheckWord(
+ ASCIIToUTF16(kTestCases[i].input).c_str(),
+ static_cast<int>(input_length),
+ 0,
+ &misspelling_start,
+ &misspelling_length, NULL);
+
+ EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].input <<
+ " in " << kLocales[j];
+ }
+ }
+
+ // Now verify that neither of testCases show up as suggestions.
+ for (size_t d = 0; d < arraysize(kLocales); ++d) {
+ ReinitializeSpellCheck(kLocales[d]);
+ int misspelling_start;
+ int misspelling_length;
+ std::vector<string16> suggestions;
+ spell_check()->SpellCheckWord(
+ ASCIIToUTF16("suckerbert").c_str(),
+ 10,
+ 0,
+ &misspelling_start,
+ &misspelling_length,
+ &suggestions);
+ // Check if the suggested words occur.
+ for (int j = 0; j < static_cast<int>(suggestions.size()); j++) {
+ for (size_t t = 0; t < test_cases_size; t++) {
+ int compare_result =
+ suggestions.at(j).compare(ASCIIToUTF16(kTestCases[t].input));
+ EXPECT_FALSE(compare_result == 0) << kTestCases[t].input <<
+ " in " << kLocales[d];
+ }
+ }
+ }
+}
+
#endif
« no previous file with comments | « chrome/common/spellcheck_common.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698