From 8fc0c4db979ee2f2d2423378dd3b9d102d9045c0 Mon Sep 17 00:00:00 2001 From: "shess@chromium.org" Date: Thu, 5 Mar 2009 01:20:56 +0000 Subject: Changes spellcheck_unittest to read dictionaries directly from the src tree. Removes the build rules to copy test dictionaries to Dictionaries/. Review URL: http://codereview.chromium.org/40082 Patch from rohitrao. git-svn-id: svn://svn.chromium.org/chrome/trunk/src@10951 0039d316-1c4b-4281-b951-d872f2087c98 --- chrome/browser/spellcheck_unittest.cc | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) (limited to 'chrome/browser/spellcheck_unittest.cc') diff --git a/chrome/browser/spellcheck_unittest.cc b/chrome/browser/spellcheck_unittest.cc index 0378ad4..cf3fe1b 100644 --- a/chrome/browser/spellcheck_unittest.cc +++ b/chrome/browser/spellcheck_unittest.cc @@ -26,6 +26,18 @@ class SpellCheckTest : public testing::Test { extern void InitHunspellWithFiles(FILE* file_aff_hunspell, FILE* file_dic_hunspell); +FilePath GetHunspellDirectory() { + FilePath hunspell_directory; + if (!PathService::Get(base::DIR_SOURCE_ROOT, &hunspell_directory)) + return FilePath(); + + hunspell_directory = hunspell_directory.AppendASCII("chrome"); + hunspell_directory = hunspell_directory.AppendASCII("third_party"); + hunspell_directory = hunspell_directory.AppendASCII("hunspell"); + hunspell_directory = hunspell_directory.AppendASCII("dictionaries"); + return hunspell_directory; +} + // Operates unit tests for the webkit_glue::SpellCheckWord() function // with the US English dictionary. // The unit tests in this function consist of: @@ -249,9 +261,8 @@ TEST_F(SpellCheckTest, SpellCheckStrings_EN_US) { {L"ifmmp:ifmmp", false, 0, 11}, }; - FilePath hunspell_directory; - ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, - &hunspell_directory)); + FilePath hunspell_directory = GetHunspellDirectory(); + ASSERT_FALSE(hunspell_directory.empty()); scoped_refptr spell_checker(new SpellChecker( hunspell_directory, L"en-US", NULL, FilePath())); @@ -303,9 +314,8 @@ TEST_F(SpellCheckTest, SpellCheckSuggestions_EN_US) { // TODO (Sidchat): add many more examples. }; - FilePath hunspell_directory; - ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, - &hunspell_directory)); + FilePath hunspell_directory = GetHunspellDirectory(); + ASSERT_FALSE(hunspell_directory.empty()); scoped_refptr spell_checker(new SpellChecker( hunspell_directory, L"en-US", NULL, FilePath())); @@ -351,10 +361,9 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckAddToDictionary_EN_US) { {L"Googler"}, }; - FilePath hunspell_directory; FilePath custom_dictionary_file(kTempCustomDictionaryFile); - ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, - &hunspell_directory)); + FilePath hunspell_directory = GetHunspellDirectory(); + ASSERT_FALSE(hunspell_directory.empty()); scoped_refptr spell_checker(new SpellChecker( hunspell_directory, L"en-US", NULL, custom_dictionary_file)); @@ -420,10 +429,9 @@ TEST_F(SpellCheckTest, DISABLED_SpellCheckSuggestionsAddToDictionary_EN_US) { {L"Googler"}, }; - FilePath hunspell_directory; FilePath custom_dictionary_file(kTempCustomDictionaryFile); - ASSERT_TRUE(PathService::Get(chrome::DIR_APP_DICTIONARIES, - &hunspell_directory)); + FilePath hunspell_directory = GetHunspellDirectory(); + ASSERT_FALSE(hunspell_directory.empty()); scoped_refptr spell_checker(new SpellChecker( hunspell_directory, L"en-US", NULL, custom_dictionary_file)); -- cgit v1.1