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