| 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 1123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1134 0, | 1134 0, |
| 1135 &misspelling_start, | 1135 &misspelling_start, |
| 1136 &misspelling_length, NULL); | 1136 &misspelling_length, NULL); |
| 1137 | 1137 |
| 1138 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].input << | 1138 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].input << |
| 1139 " in " << kLocales[j]; | 1139 " in " << kLocales[j]; |
| 1140 } | 1140 } |
| 1141 } | 1141 } |
| 1142 } | 1142 } |
| 1143 | 1143 |
| 1144 // Checks that NOSUGGEST works in English dictionaries. |
| 1145 TEST_F(SpellCheckTest, NoSuggest) { |
| 1146 static const struct { |
| 1147 const char* input; |
| 1148 bool should_pass; |
| 1149 } kTestCases[] = { |
| 1150 {"cocksucker", true}, |
| 1151 {"cocksuckers", true}, |
| 1152 }; |
| 1153 |
| 1154 static const char* kLocales[] = { "en-GB", "en-US", "en-CA", "en-AU" }; |
| 1155 |
| 1156 // First check that the NOSUGGEST flag didn't mark these words as not |
| 1157 // being in the dictionary. |
| 1158 size_t test_cases_size = ARRAYSIZE_UNSAFE(kTestCases); |
| 1159 for (size_t j = 0; j < arraysize(kLocales); ++j) { |
| 1160 ReinitializeSpellCheck(kLocales[j]); |
| 1161 for (size_t i = 0; i < test_cases_size; ++i) { |
| 1162 size_t input_length = 0; |
| 1163 if (kTestCases[i].input != NULL) |
| 1164 input_length = strlen(kTestCases[i].input); |
| 1165 |
| 1166 int misspelling_start = 0; |
| 1167 int misspelling_length = 0; |
| 1168 bool result = spell_check()->SpellCheckWord( |
| 1169 ASCIIToUTF16(kTestCases[i].input).c_str(), |
| 1170 static_cast<int>(input_length), |
| 1171 0, |
| 1172 &misspelling_start, |
| 1173 &misspelling_length, NULL); |
| 1174 |
| 1175 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].input << |
| 1176 " in " << kLocales[j]; |
| 1177 } |
| 1178 } |
| 1179 |
| 1180 // Now verify that neither of testCases show up as suggestions. |
| 1181 for (size_t d = 0; d < arraysize(kLocales); ++d) { |
| 1182 ReinitializeSpellCheck(kLocales[d]); |
| 1183 int misspelling_start; |
| 1184 int misspelling_length; |
| 1185 std::vector<string16> suggestions; |
| 1186 spell_check()->SpellCheckWord( |
| 1187 ASCIIToUTF16("suckerbert").c_str(), |
| 1188 10, |
| 1189 0, |
| 1190 &misspelling_start, |
| 1191 &misspelling_length, |
| 1192 &suggestions); |
| 1193 // Check if the suggested words occur. |
| 1194 for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { |
| 1195 for (size_t t = 0; t < test_cases_size; t++) { |
| 1196 int compare_result = |
| 1197 suggestions.at(j).compare(ASCIIToUTF16(kTestCases[t].input)); |
| 1198 EXPECT_FALSE(compare_result == 0) << kTestCases[t].input << |
| 1199 " in " << kLocales[d]; |
| 1200 } |
| 1201 } |
| 1202 } |
| 1203 } |
| 1204 |
| 1144 #endif | 1205 #endif |
| OLD | NEW |