| 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 "components/spellcheck/renderer/spellcheck.h" | 5 #include "components/spellcheck/renderer/spellcheck.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <memory> | 9 #include <memory> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 1315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1326 bool result = spell_check()->SpellCheckWord( | 1326 bool result = spell_check()->SpellCheckWord( |
| 1327 base::ASCIIToUTF16(kTestCases[i].suggestion).c_str(), | 1327 base::ASCIIToUTF16(kTestCases[i].suggestion).c_str(), |
| 1328 kNoOffset, | 1328 kNoOffset, |
| 1329 static_cast<int>(suggestion_length), | 1329 static_cast<int>(suggestion_length), |
| 1330 kNoTag, | 1330 kNoTag, |
| 1331 &misspelling_start, | 1331 &misspelling_start, |
| 1332 &misspelling_length, NULL); | 1332 &misspelling_length, NULL); |
| 1333 | 1333 |
| 1334 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].suggestion << | 1334 EXPECT_EQ(kTestCases[i].should_pass, result) << kTestCases[i].suggestion << |
| 1335 " in " << kTestCases[i].locale; | 1335 " in " << kTestCases[i].locale; |
| 1336 | 1336 // TODO(cb/673424): Bring this back when suggestions are sped up. |
| 1337 #if 0 |
| 1337 // Now verify that this test case does not show up as a suggestion. | 1338 // Now verify that this test case does not show up as a suggestion. |
| 1338 std::vector<base::string16> suggestions; | 1339 std::vector<base::string16> suggestions; |
| 1339 size_t input_length = 0; | 1340 size_t input_length = 0; |
| 1340 if (kTestCases[i].input != NULL) | 1341 if (kTestCases[i].input != NULL) |
| 1341 input_length = strlen(kTestCases[i].input); | 1342 input_length = strlen(kTestCases[i].input); |
| 1342 result = spell_check()->SpellCheckWord( | 1343 result = spell_check()->SpellCheckWord( |
| 1343 base::ASCIIToUTF16(kTestCases[i].input).c_str(), | 1344 base::ASCIIToUTF16(kTestCases[i].input).c_str(), |
| 1344 kNoOffset, | 1345 kNoOffset, |
| 1345 static_cast<int>(input_length), | 1346 static_cast<int>(input_length), |
| 1346 kNoTag, | 1347 kNoTag, |
| 1347 &misspelling_start, | 1348 &misspelling_start, |
| 1348 &misspelling_length, | 1349 &misspelling_length, |
| 1349 &suggestions); | 1350 &suggestions); |
| 1350 // Input word should be a misspelling. | 1351 // Input word should be a misspelling. |
| 1351 EXPECT_FALSE(result) << kTestCases[i].input | 1352 EXPECT_FALSE(result) << kTestCases[i].input |
| 1352 << " is not a misspelling in " | 1353 << " is not a misspelling in " |
| 1353 << kTestCases[i].locale; | 1354 << kTestCases[i].locale; |
| 1354 // Check if the suggested words occur. | 1355 // Check if the suggested words occur. |
| 1355 for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { | 1356 for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { |
| 1356 for (size_t t = 0; t < test_cases_size; t++) { | 1357 for (size_t t = 0; t < test_cases_size; t++) { |
| 1357 int compare_result = suggestions.at(j).compare( | 1358 int compare_result = suggestions.at(j).compare( |
| 1358 base::ASCIIToUTF16(kTestCases[t].suggestion)); | 1359 base::ASCIIToUTF16(kTestCases[t].suggestion)); |
| 1359 EXPECT_FALSE(compare_result == 0) << kTestCases[t].suggestion << | 1360 EXPECT_FALSE(compare_result == 0) << kTestCases[t].suggestion << |
| 1360 " in " << kTestCases[i].locale; | 1361 " in " << kTestCases[i].locale; |
| 1361 } | 1362 } |
| 1362 } | 1363 } |
| 1364 #endif |
| 1363 } | 1365 } |
| 1364 } | 1366 } |
| 1365 | 1367 |
| 1366 // Check that the correct dictionary files are checked in. | 1368 // Check that the correct dictionary files are checked in. |
| 1367 TEST_F(SpellCheckTest, DictionaryFiles) { | 1369 TEST_F(SpellCheckTest, DictionaryFiles) { |
| 1368 std::vector<std::string> spellcheck_languages; | 1370 std::vector<std::string> spellcheck_languages; |
| 1369 spellcheck::SpellCheckLanguages(&spellcheck_languages); | 1371 spellcheck::SpellCheckLanguages(&spellcheck_languages); |
| 1370 EXPECT_FALSE(spellcheck_languages.empty()); | 1372 EXPECT_FALSE(spellcheck_languages.empty()); |
| 1371 | 1373 |
| 1372 base::FilePath hunspell = GetHunspellDirectory(); | 1374 base::FilePath hunspell = GetHunspellDirectory(); |
| (...skipping 188 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1561 // to be updated accordingly. | 1563 // to be updated accordingly. |
| 1562 ASSERT_EQ(5, spellcheck::kMaxSuggestions); | 1564 ASSERT_EQ(5, spellcheck::kMaxSuggestions); |
| 1563 FillSuggestions(suggestions_list, &suggestion_results); | 1565 FillSuggestions(suggestions_list, &suggestion_results); |
| 1564 ASSERT_EQ(5U, suggestion_results.size()); | 1566 ASSERT_EQ(5U, suggestion_results.size()); |
| 1565 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); | 1567 EXPECT_EQ(base::ASCIIToUTF16("0foo"), suggestion_results[0]); |
| 1566 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); | 1568 EXPECT_EQ(base::ASCIIToUTF16("1foo"), suggestion_results[1]); |
| 1567 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); | 1569 EXPECT_EQ(base::ASCIIToUTF16("2foo"), suggestion_results[2]); |
| 1568 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); | 1570 EXPECT_EQ(base::ASCIIToUTF16("0bar"), suggestion_results[3]); |
| 1569 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); | 1571 EXPECT_EQ(base::ASCIIToUTF16("1bar"), suggestion_results[4]); |
| 1570 } | 1572 } |
| OLD | NEW |