summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--chrome/browser/spellchecker/spellcheck_custom_dictionary.cc4
-rw-r--r--chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc16
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();