diff options
author | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 20:44:08 +0000 |
---|---|---|
committer | estade@chromium.org <estade@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-02-25 20:44:08 +0000 |
commit | bd17b70920f5a327eada613ef32e501b043cad51 (patch) | |
tree | 7d6deb4e24373ceb2ea9affb9fdd9dab5a1f6482 /chrome/browser/spellcheck_unittest.cc | |
parent | a12f3755769dea04a41785657c37dc90b443caaf (diff) | |
download | chromium_src-bd17b70920f5a327eada613ef32e501b043cad51.zip chromium_src-bd17b70920f5a327eada613ef32e501b043cad51.tar.gz chromium_src-bd17b70920f5a327eada613ef32e501b043cad51.tar.bz2 |
Ports SpellChecker to use FilePaths instead of wstring.
by Rohit Rao (rohitrao@google.com)
issue: http://codereview.chromium.org/28013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10374 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/spellcheck_unittest.cc')
-rw-r--r-- | chrome/browser/spellcheck_unittest.cc | 37 |
1 files changed, 20 insertions, 17 deletions
diff --git a/chrome/browser/spellcheck_unittest.cc b/chrome/browser/spellcheck_unittest.cc index 745cd6e..d0fa608 100644 --- a/chrome/browser/spellcheck_unittest.cc +++ b/chrome/browser/spellcheck_unittest.cc @@ -17,7 +17,8 @@ class SpellCheckTest : public testing::Test { MessageLoop message_loop_; }; -const std::wstring kTempCustomDictionaryFile(L"temp_custom_dictionary.txt"); +const FilePath::CharType kTempCustomDictionaryFile[] = + FILE_PATH_LITERAL("temp_custom_dictionary.txt"); } // namespace @@ -249,12 +250,12 @@ TEST_F(SpellCheckTest, SpellCheckStrings_EN_US) { {L"ifmmp:ifmmp", false, 0, 11}, }; - std::wstring hunspell_directory; + FilePath hunspell_directory; ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &hunspell_directory)); scoped_refptr<SpellChecker> spell_checker(new SpellChecker( - hunspell_directory, L"en-US", NULL, std::wstring())); + hunspell_directory, L"en-US", NULL, FilePath())); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { size_t input_length = 0; @@ -268,9 +269,9 @@ TEST_F(SpellCheckTest, SpellCheckStrings_EN_US) { &misspelling_start, &misspelling_length, NULL); - EXPECT_EQ(result, kTestCases[i].expected_result); - EXPECT_EQ(misspelling_start, kTestCases[i].misspelling_start); - EXPECT_EQ(misspelling_length, kTestCases[i].misspelling_length); + EXPECT_EQ(kTestCases[i].expected_result, result); + EXPECT_EQ(kTestCases[i].misspelling_start, misspelling_start); + EXPECT_EQ(kTestCases[i].misspelling_length, misspelling_length); } } @@ -303,12 +304,12 @@ TEST_F(SpellCheckTest, SpellCheckSuggestions_EN_US) { // TODO (Sidchat): add many more examples. }; - std::wstring hunspell_directory; + FilePath hunspell_directory; ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &hunspell_directory)); scoped_refptr<SpellChecker> spell_checker(new SpellChecker( - hunspell_directory, L"en-US", NULL, std::wstring())); + hunspell_directory, L"en-US", NULL, FilePath())); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { std::vector<std::wstring> suggestions; @@ -325,7 +326,7 @@ TEST_F(SpellCheckTest, SpellCheckSuggestions_EN_US) { &suggestions); // Check for spelling. - EXPECT_EQ(result, kTestCases[i].expected_result); + EXPECT_EQ(kTestCases[i].expected_result, result); // Check if the suggested words occur. bool suggested_word_is_present = false; @@ -351,12 +352,13 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckAddToDictionary_EN_US) { {L"Googler"}, }; - std::wstring hunspell_directory; + FilePath hunspell_directory; + FilePath custom_dictionary_file(kTempCustomDictionaryFile); ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &hunspell_directory)); scoped_refptr<SpellChecker> spell_checker(new SpellChecker( - hunspell_directory, L"en-US", NULL, kTempCustomDictionaryFile)); + hunspell_directory, L"en-US", NULL, custom_dictionary_file)); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { // Add the word to spellchecker. @@ -382,7 +384,7 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckAddToDictionary_EN_US) { // Now initialize another spellchecker to see that AddToWord is permanent. scoped_refptr<SpellChecker> spell_checker_new(new SpellChecker( - hunspell_directory, L"en-US", NULL, kTempCustomDictionaryFile)); + hunspell_directory, L"en-US", NULL, custom_dictionary_file)); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { // Now check whether it is added to Spellchecker. @@ -405,7 +407,7 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckAddToDictionary_EN_US) { } // Remove the temp custom dictionary file. - file_util::Delete(kTempCustomDictionaryFile, false); + file_util::Delete(custom_dictionary_file, false); } // SpellChecker should suggest custome words for misspelled words. @@ -419,19 +421,20 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckSuggestionsAddToDictionary_EN_US) { {L"Googler"}, }; - std::wstring hunspell_directory; + FilePath hunspell_directory; + FilePath custom_dictionary_file(kTempCustomDictionaryFile); ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, &hunspell_directory)); scoped_refptr<SpellChecker> spell_checker(new SpellChecker( - hunspell_directory, L"en-US", NULL, kTempCustomDictionaryFile)); + hunspell_directory, L"en-US", NULL, custom_dictionary_file)); for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kTestCases); ++i) { // Add the word to spellchecker. spell_checker->AddWord(std::wstring(kTestCases[i].word_to_add)); } - // Now check to see whether the custom words are suggested for + // Now check to see whether the custom words are suggested for // misspelled but similar words. static const struct { // A string to be tested. @@ -483,5 +486,5 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckSuggestionsAddToDictionary_EN_US) { } // Remove the temp custom dictionary file. - file_util::Delete(kTempCustomDictionaryFile, false); + file_util::Delete(custom_dictionary_file, false); } |