| 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 775 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 786 string16 expected_autocorrect_word( | 786 string16 expected_autocorrect_word( |
| 787 UTF8ToUTF16(kTestCases[i].expected_result)); | 787 UTF8ToUTF16(kTestCases[i].expected_result)); |
| 788 string16 autocorrect_word = spell_check()->GetAutoCorrectionWord( | 788 string16 autocorrect_word = spell_check()->GetAutoCorrectionWord( |
| 789 misspelled_word, 0); | 789 misspelled_word, 0); |
| 790 | 790 |
| 791 // Check for spelling. | 791 // Check for spelling. |
| 792 EXPECT_EQ(expected_autocorrect_word, autocorrect_word); | 792 EXPECT_EQ(expected_autocorrect_word, autocorrect_word); |
| 793 } | 793 } |
| 794 } | 794 } |
| 795 | 795 |
| 796 // Verify that our SpellCheck::SpellCheckWord() returns false when it checks |
| 797 // misspelled words. |
| 798 TEST_F(SpellCheckTest, MisspelledWords) { |
| 799 static const struct { |
| 800 const char* language; |
| 801 const wchar_t* input; |
| 802 } kTestCases[] = { |
| 803 { |
| 804 // A misspelled word for English |
| 805 "en-US", |
| 806 L"aaaaaaaaaa", |
| 807 }, { |
| 808 // A misspelled word for Greek. |
| 809 "el-GR", |
| 810 L"\x03B1\x03B1\x03B1\x03B1\x03B1\x03B1\x03B1\x03B1\x03B1\x03B1", |
| 811 }, { |
| 812 // A misspelled word for Hebrew |
| 813 "he-IL", |
| 814 L"\x05D0\x05D0\x05D0\x05D0\x05D0\x05D0\x05D0\x05D0\x05D0\x05D0", |
| 815 }, { |
| 816 // Hindi |
| 817 "hi-IN", |
| 818 L"\x0905\x0905\x0905\x0905\x0905\x0905\x0905\x0905\x0905\x0905", |
| 819 }, { |
| 820 // A misspelled word for Russian |
| 821 "ru-RU", |
| 822 L"\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430\x0430", |
| 823 }, |
| 824 }; |
| 825 |
| 826 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { |
| 827 ReinitializeSpellCheck(kTestCases[i].language); |
| 828 |
| 829 string16 word(WideToUTF16(kTestCases[i].input)); |
| 830 int word_length = static_cast<int>(word.length()); |
| 831 int misspelling_start = 0; |
| 832 int misspelling_length = 0; |
| 833 bool result = spell_check()->SpellCheckWord(word.c_str(), |
| 834 word_length, |
| 835 0, |
| 836 &misspelling_start, |
| 837 &misspelling_length, |
| 838 NULL); |
| 839 EXPECT_FALSE(result); |
| 840 EXPECT_EQ(0, misspelling_start); |
| 841 EXPECT_EQ(word_length, misspelling_length); |
| 842 } |
| 843 } |
| 844 |
| 796 // Since SpellCheck::SpellCheckParagraph is not implemented on Mac, | 845 // Since SpellCheck::SpellCheckParagraph is not implemented on Mac, |
| 797 // we skip these SpellCheckParagraph tests on Mac. | 846 // we skip these SpellCheckParagraph tests on Mac. |
| 798 #if !defined(OS_MACOSX) | 847 #if !defined(OS_MACOSX) |
| 799 | 848 |
| 800 // Make sure SpellCheckParagraph does not crash if the input is empty. | 849 // Make sure SpellCheckParagraph does not crash if the input is empty. |
| 801 TEST_F(SpellCheckTest, SpellCheckParagraphEmptyParagraph) { | 850 TEST_F(SpellCheckTest, SpellCheckParagraphEmptyParagraph) { |
| 802 std::vector<SpellCheckResult> expected; | 851 std::vector<SpellCheckResult> expected; |
| 803 TestSpellCheckParagraph(UTF8ToUTF16(""), expected); | 852 TestSpellCheckParagraph(UTF8ToUTF16(""), expected); |
| 804 } | 853 } |
| 805 | 854 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1032 spell_check()->CreateTextCheckingResults( | 1081 spell_check()->CreateTextCheckingResults( |
| 1033 0, text, spellcheck_results, &textcheck_results); | 1082 0, text, spellcheck_results, &textcheck_results); |
| 1034 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); | 1083 EXPECT_EQ(spellcheck_results.size(), textcheck_results.size()); |
| 1035 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); | 1084 EXPECT_EQ(WebKit::WebTextCheckingTypeGrammar, textcheck_results[0].type); |
| 1036 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); | 1085 EXPECT_EQ(spellcheck_results[0].location, textcheck_results[0].location); |
| 1037 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); | 1086 EXPECT_EQ(spellcheck_results[0].length, textcheck_results[0].length); |
| 1038 } | 1087 } |
| 1039 } | 1088 } |
| 1040 | 1089 |
| 1041 #endif | 1090 #endif |
| OLD | NEW |