diff options
author | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 20:32:47 +0000 |
---|---|---|
committer | rouslan@chromium.org <rouslan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-11-20 20:32:47 +0000 |
commit | a887abfbb9004add60704e8a7148ccd5d89d9e60 (patch) | |
tree | 2efd6020796bd8d07110c698886276200945677e /chrome/browser/spellchecker | |
parent | 8c197e505cd05525768826f46aa1d0e0d6058435 (diff) | |
download | chromium_src-a887abfbb9004add60704e8a7148ccd5d89d9e60.zip chromium_src-a887abfbb9004add60704e8a7148ccd5d89d9e60.tar.gz chromium_src-a887abfbb9004add60704e8a7148ccd5d89d9e60.tar.bz2 |
Unit-tests for removing words from the dictionary
BUG=161361
Review URL: https://chromiumcodereview.appspot.com/11280013
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@168863 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/spellchecker')
-rw-r--r-- | chrome/browser/spellchecker/spellcheck_custom_dictionary.cc | 4 | ||||
-rw-r--r-- | chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc | 16 |
2 files changed, 16 insertions, 4 deletions
diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc index 1d8ce84..b793b27 100644 --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary.cc @@ -49,8 +49,10 @@ void SpellcheckCustomDictionary::LoadDictionaryIntoCustomWordList( std::string contents; file_util::ReadFileToString(custom_dictionary_path_, &contents); - if (contents.empty()) + if (contents.empty()) { + custom_words->clear(); return; + } base::SplitString(contents, '\n', custom_words); // Clear out empty words. diff --git a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc index b5fb425..bdbc15e 100644 --- a/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc +++ b/chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc @@ -45,7 +45,6 @@ class SpellcheckCustomDictionaryTest : public testing::Test { scoped_ptr<TestingProfile> profile_; }; -// TODO(rlp/rouslan): Shift some of these to a cutsom dictionary test suite. TEST_F(SpellcheckCustomDictionaryTest, SpellcheckSetCustomWordList) { SpellcheckService* spellcheck_service = SpellcheckServiceFactory::GetForProfile(profile_.get()); @@ -60,14 +59,13 @@ TEST_F(SpellcheckCustomDictionaryTest, SpellcheckSetCustomWordList) { EXPECT_EQ(custom_dictionary->GetWords(), expected); } -TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) { +TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedAndRemovedLocally) { SpellcheckService* spellcheck_service = SpellcheckServiceFactory::GetForProfile(profile_.get()); WordList loaded_custom_words; SpellcheckCustomDictionary* custom_dictionary = spellcheck_service->GetCustomDictionary(); - custom_dictionary->Load(); WordList expected; EXPECT_EQ(custom_dictionary->GetWords(), expected); custom_dictionary->CustomWordAddedLocally("foo"); @@ -76,6 +74,11 @@ TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) { custom_dictionary->CustomWordAddedLocally("bar"); expected.push_back("bar"); EXPECT_EQ(custom_dictionary->GetWords(), expected); + + custom_dictionary->CustomWordRemovedLocally("foo"); + custom_dictionary->CustomWordRemovedLocally("bar"); + expected.clear(); + EXPECT_EQ(custom_dictionary->GetWords(), expected); } TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { @@ -108,6 +111,13 @@ TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { spellcheck_service2.GetCustomDictionary()-> LoadDictionaryIntoCustomWordList(&loaded_custom_words2); EXPECT_EQ(loaded_custom_words2, expected); + + custom_dictionary->EraseWordFromCustomDictionary("foo"); + custom_dictionary->EraseWordFromCustomDictionary("bar"); + custom_dictionary->LoadDictionaryIntoCustomWordList(&loaded_custom_words); + expected.clear(); + EXPECT_EQ(loaded_custom_words, expected); + // Flush the loop now to prevent service init tasks from being run during // TearDown(); MessageLoop::current()->RunUntilIdle(); |