| OLD | NEW |
| 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 "webkit/glue/webkit_glue.h" | 5 #include "webkit/glue/webkit_glue.h" |
| 6 | 6 |
| 7 #include "base/file_util.h" | 7 #include "base/file_util.h" |
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "base/platform_file.h" | 10 #include "base/platform_file.h" |
| (...skipping 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 351 {L"7th", true}, | 351 {L"7th", true}, |
| 352 {L"8th", true}, | 352 {L"8th", true}, |
| 353 {L"9th", true}, | 353 {L"9th", true}, |
| 354 {L"10th", true}, | 354 {L"10th", true}, |
| 355 {L"100th", true}, | 355 {L"100th", true}, |
| 356 {L"1000th", true}, | 356 {L"1000th", true}, |
| 357 {L"25", true}, | 357 {L"25", true}, |
| 358 {L"2012", true}, | 358 {L"2012", true}, |
| 359 {L"100,000,000", true}, | 359 {L"100,000,000", true}, |
| 360 {L"3.141592653", true}, | 360 {L"3.141592653", true}, |
| 361 |
| 361 }; | 362 }; |
| 362 | 363 |
| 363 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 364 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 364 size_t input_length = 0; | 365 size_t input_length = 0; |
| 365 if (kTestCases[i].input != NULL) { | 366 if (kTestCases[i].input != NULL) { |
| 366 input_length = wcslen(kTestCases[i].input); | 367 input_length = wcslen(kTestCases[i].input); |
| 367 } | 368 } |
| 368 int misspelling_start; | 369 int misspelling_start; |
| 369 int misspelling_length; | 370 int misspelling_length; |
| 370 bool result = spell_check()->SpellCheckWord( | 371 bool result = spell_check()->SpellCheckWord( |
| (...skipping 709 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1080 WebKit::WebVector<WebKit::WebTextCheckingResult> textcheck_results; | 1081 WebKit::WebVector<WebKit::WebTextCheckingResult> textcheck_results; |
| 1081 spell_check()->CreateTextCheckingResults( | 1082 spell_check()->CreateTextCheckingResults( |
| 1082 0, text, spellcheck_results, &textcheck_results); | 1083 0, text, spellcheck_results, &textcheck_results); |
| 1083 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); | 1084 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); |
| 1084 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); | 1085 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); |
| 1085 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); | 1086 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); |
| 1086 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); | 1087 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); |
| 1087 } | 1088 } |
| 1088 } | 1089 } |
| 1089 | 1090 |
| 1091 // Checks some words that should be present in all English dictionaries. |
| 1092 TEST_F(SpellCheckTest, EnglishWords) { |
| 1093 static const struct { |
| 1094 const char* input; |
| 1095 bool should_pass; |
| 1096 } kTestCases[] = { |
| 1097 // Issue 146093: "Chromebook" and "Chromebox" not included in spell-checking |
| 1098 // dictionary. |
| 1099 {"Chromebook", true}, |
| 1100 {"Chromebooks", true}, |
| 1101 {"Chromebox", true}, |
| 1102 {"Chromeboxes", true}, |
| 1103 {"Chromeblade", true}, |
| 1104 {"Chromeblades", true}, |
| 1105 {"Chromebase", true}, |
| 1106 {"Chromebases", true}, |
| 1107 // Issue 94708: Spell-checker incorrectly reports whisky as misspelled. |
| 1108 {"whisky", true}, |
| 1109 {"whiskey", true}, |
| 1110 {"whiskies", true}, |
| 1111 // Issue 98678: "Recency" should be included in client-side dictionary. |
| 1112 {"recency", true}, |
| 1113 {"recencies", false}, |
| 1114 // Issue 140486 |
| 1115 {"movie", true}, |
| 1116 {"movies", true}, |
| 1117 }; |
| 1118 |
| 1119 static const char* kLocales[] = { "en-GB", "en-US", "en-CA", "en-AU" }; |
| 1120 |
| 1121 for (size_t j = 0; j < arraysize(kLocales); ++j) { |
| 1122 ReinitializeSpellCheck(kLocales[j]); |
| 1123 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 1124 size_t input_length = 0; |
| 1125 if (kTestCases[i].input != NULL) |
| 1126 input_length = strlen(kTestCases[i].input); |
| 1127 |
| 1128 int misspelling_start = 0; |
| 1129 int misspelling_length = 0; |
| 1130 bool result = spell_check()->SpellCheckWord( |
| 1131 ASCIIToUTF16(kTestCases[i].input).c_str(), |
| 1132 static_cast<int>(input_length), |
| 1133 0, |
| 1134 &misspelling_start, |
| 1135 &misspelling_length, NULL); |
| 1136 |
| 1137 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].input << |
| 1138 " in " << kLocales[j]; |
| 1139 } |
| 1140 } |
| 1141 } |
| 1142 |
| 1090 #endif | 1143 #endif |
| OLD | NEW |