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 372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
383 }; | 383 }; |
384 | 384 |
385 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 385 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
386 size_t input_length = 0; | 386 size_t input_length = 0; |
387 if (kTestCases[i].input != NULL) { | 387 if (kTestCases[i].input != NULL) { |
388 input_length = wcslen(kTestCases[i].input); | 388 input_length = wcslen(kTestCases[i].input); |
389 } | 389 } |
390 int misspelling_start; | 390 int misspelling_start; |
391 int misspelling_length; | 391 int misspelling_length; |
392 bool result = spell_check()->SpellCheckWord( | 392 bool result = spell_check()->SpellCheckWord( |
393 WideToUTF16(kTestCases[i].input).c_str(), | 393 base::WideToUTF16(kTestCases[i].input).c_str(), |
394 static_cast<int>(input_length), | 394 static_cast<int>(input_length), |
395 0, | 395 0, |
396 &misspelling_start, | 396 &misspelling_start, |
397 &misspelling_length, NULL); | 397 &misspelling_length, NULL); |
398 | 398 |
399 EXPECT_EQ(kTestCases[i].expected_result, result); | 399 EXPECT_EQ(kTestCases[i].expected_result, result); |
400 EXPECT_EQ(kTestCases[i].misspelling_start, misspelling_start); | 400 EXPECT_EQ(kTestCases[i].misspelling_start, misspelling_start); |
401 EXPECT_EQ(kTestCases[i].misspelling_length, misspelling_length); | 401 EXPECT_EQ(kTestCases[i].misspelling_length, misspelling_length); |
402 } | 402 } |
403 } | 403 } |
(...skipping 30 matching lines...) Expand all Loading... |
434 | 434 |
435 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 435 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
436 std::vector<string16> suggestions; | 436 std::vector<string16> suggestions; |
437 size_t input_length = 0; | 437 size_t input_length = 0; |
438 if (kTestCases[i].input != NULL) { | 438 if (kTestCases[i].input != NULL) { |
439 input_length = wcslen(kTestCases[i].input); | 439 input_length = wcslen(kTestCases[i].input); |
440 } | 440 } |
441 int misspelling_start; | 441 int misspelling_start; |
442 int misspelling_length; | 442 int misspelling_length; |
443 bool result = spell_check()->SpellCheckWord( | 443 bool result = spell_check()->SpellCheckWord( |
444 WideToUTF16(kTestCases[i].input).c_str(), | 444 base::WideToUTF16(kTestCases[i].input).c_str(), |
445 static_cast<int>(input_length), | 445 static_cast<int>(input_length), |
446 0, | 446 0, |
447 &misspelling_start, | 447 &misspelling_start, |
448 &misspelling_length, | 448 &misspelling_length, |
449 &suggestions); | 449 &suggestions); |
450 | 450 |
451 // Check for spelling. | 451 // Check for spelling. |
452 EXPECT_EQ(kTestCases[i].expected_result, result); | 452 EXPECT_EQ(kTestCases[i].expected_result, result); |
453 | 453 |
454 // Check if the suggested words occur. | 454 // Check if the suggested words occur. |
455 bool suggested_word_is_present = false; | 455 bool suggested_word_is_present = false; |
456 for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { | 456 for (int j = 0; j < static_cast<int>(suggestions.size()); j++) { |
457 if (suggestions.at(j).compare(WideToUTF16(kTestCases[i].suggested_word)) | 457 if (suggestions.at(j).compare(base::WideToUTF16( |
458 == 0) { | 458 kTestCases[i].suggested_word)) == 0) { |
459 suggested_word_is_present = true; | 459 suggested_word_is_present = true; |
460 break; | 460 break; |
461 } | 461 } |
462 } | 462 } |
463 | 463 |
464 EXPECT_TRUE(suggested_word_is_present); | 464 EXPECT_TRUE(suggested_word_is_present); |
465 } | 465 } |
466 } | 466 } |
467 | 467 |
468 // This test verifies our spellchecker can split a text into words and check | 468 // This test verifies our spellchecker can split a text into words and check |
(...skipping 323 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
792 | 792 |
793 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 793 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
794 ReinitializeSpellCheck(kTestCases[i].language); | 794 ReinitializeSpellCheck(kTestCases[i].language); |
795 size_t input_length = 0; | 795 size_t input_length = 0; |
796 if (kTestCases[i].input != NULL) | 796 if (kTestCases[i].input != NULL) |
797 input_length = wcslen(kTestCases[i].input); | 797 input_length = wcslen(kTestCases[i].input); |
798 | 798 |
799 int misspelling_start = 0; | 799 int misspelling_start = 0; |
800 int misspelling_length = 0; | 800 int misspelling_length = 0; |
801 bool result = spell_check()->SpellCheckWord( | 801 bool result = spell_check()->SpellCheckWord( |
802 WideToUTF16(kTestCases[i].input).c_str(), | 802 base::WideToUTF16(kTestCases[i].input).c_str(), |
803 static_cast<int>(input_length), | 803 static_cast<int>(input_length), |
804 0, | 804 0, |
805 &misspelling_start, | 805 &misspelling_start, |
806 &misspelling_length, NULL); | 806 &misspelling_length, NULL); |
807 | 807 |
808 EXPECT_TRUE(result) | 808 EXPECT_TRUE(result) |
809 << "\"" | 809 << "\"" |
810 << std::wstring(kTestCases[i].input).substr( | 810 << std::wstring(kTestCases[i].input).substr( |
811 misspelling_start, misspelling_length) | 811 misspelling_start, misspelling_length) |
812 << "\" is misspelled in " | 812 << "\" is misspelled in " |
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
873 }, { | 873 }, { |
874 // A misspelled word for Russian | 874 // A misspelled word for Russian |
875 "ru-RU", | 875 "ru-RU", |
876 L"\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430", | 876 L"\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430", |
877 }, | 877 }, |
878 }; | 878 }; |
879 | 879 |
880 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 880 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
881 ReinitializeSpellCheck(kTestCases[i].language); | 881 ReinitializeSpellCheck(kTestCases[i].language); |
882 | 882 |
883 string16 word(WideToUTF16(kTestCases[i].input)); | 883 string16 word(base::WideToUTF16(kTestCases[i].input)); |
884 int word_length = static_cast<int>(word.length()); | 884 int word_length = static_cast<int>(word.length()); |
885 int misspelling_start = 0; | 885 int misspelling_start = 0; |
886 int misspelling_length = 0; | 886 int misspelling_length = 0; |
887 bool result = spell_check()->SpellCheckWord(word.c_str(), | 887 bool result = spell_check()->SpellCheckWord(word.c_str(), |
888 word_length, | 888 word_length, |
889 0, | 889 0, |
890 &misspelling_start, | 890 &misspelling_start, |
891 &misspelling_length, | 891 &misspelling_length, |
892 NULL); | 892 NULL); |
893 EXPECT_FALSE(result); | 893 EXPECT_FALSE(result); |
(...skipping 425 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1319 InitializeIfNeeded(); | 1319 InitializeIfNeeded(); |
1320 ASSERT_FALSE(InitializeIfNeeded()); | 1320 ASSERT_FALSE(InitializeIfNeeded()); |
1321 | 1321 |
1322 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { | 1322 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
1323 bool result = CheckSpelling(kTestCases[i].word, 0); | 1323 bool result = CheckSpelling(kTestCases[i].word, 0); |
1324 EXPECT_EQ(kTestCases[i].expected_result, result) << | 1324 EXPECT_EQ(kTestCases[i].expected_result, result) << |
1325 "Failed test for " << kTestCases[i].word; | 1325 "Failed test for " << kTestCases[i].word; |
1326 } | 1326 } |
1327 } | 1327 } |
1328 | 1328 |
OLD | NEW |