Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(974)

Side by Side Diff: chrome/browser/spellchecker/spellcheck_custom_dictionary_unittest.cc

Issue 11362063: Editing the custom spelling dictionary (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 <vector> 5 #include <vector>
6 6
7 #include "base/scoped_temp_dir.h" 7 #include "base/scoped_temp_dir.h"
8 #include "chrome/browser/spellchecker/spellcheck_factory.h" 8 #include "chrome/browser/spellchecker/spellcheck_factory.h"
9 #include "chrome/browser/spellchecker/spellcheck_service.h" 9 #include "chrome/browser/spellchecker/spellcheck_service.h"
10 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" 10 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 SpellcheckService* spellcheck_service = 51 SpellcheckService* spellcheck_service =
52 SpellcheckServiceFactory::GetForProfile(profile_.get()); 52 SpellcheckServiceFactory::GetForProfile(profile_.get());
53 53
54 WordList loaded_custom_words; 54 WordList loaded_custom_words;
55 loaded_custom_words.push_back("foo"); 55 loaded_custom_words.push_back("foo");
56 loaded_custom_words.push_back("bar"); 56 loaded_custom_words.push_back("bar");
57 WordList expected(loaded_custom_words); 57 WordList expected(loaded_custom_words);
58 SpellcheckCustomDictionary* custom_dictionary = 58 SpellcheckCustomDictionary* custom_dictionary =
59 spellcheck_service->GetCustomDictionary(); 59 spellcheck_service->GetCustomDictionary();
60 custom_dictionary->SetCustomWordList(&loaded_custom_words); 60 custom_dictionary->SetCustomWordList(&loaded_custom_words);
61 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 61 EXPECT_EQ(custom_dictionary->GetWords(), expected);
62 } 62 }
63 63
64 TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) { 64 TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) {
65 SpellcheckService* spellcheck_service = 65 SpellcheckService* spellcheck_service =
66 SpellcheckServiceFactory::GetForProfile(profile_.get()); 66 SpellcheckServiceFactory::GetForProfile(profile_.get());
67 67
68 WordList loaded_custom_words; 68 WordList loaded_custom_words;
69 SpellcheckCustomDictionary* custom_dictionary = 69 SpellcheckCustomDictionary* custom_dictionary =
70 spellcheck_service->GetCustomDictionary(); 70 spellcheck_service->GetCustomDictionary();
71 custom_dictionary->Load(); 71 custom_dictionary->Load();
72 WordList expected; 72 WordList expected;
73 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 73 EXPECT_EQ(custom_dictionary->GetWords(), expected);
74 custom_dictionary->CustomWordAddedLocally("foo"); 74 custom_dictionary->CustomWordAddedLocally("foo");
75 expected.push_back("foo"); 75 expected.push_back("foo");
76 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 76 EXPECT_EQ(custom_dictionary->GetWords(), expected);
77 custom_dictionary->CustomWordAddedLocally("bar"); 77 custom_dictionary->CustomWordAddedLocally("bar");
78 expected.push_back("bar"); 78 expected.push_back("bar");
79 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 79 EXPECT_EQ(custom_dictionary->GetWords(), expected);
80 } 80 }
81 81
82 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { 82 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) {
83 SpellcheckService* spellcheck_service = 83 SpellcheckService* spellcheck_service =
84 SpellcheckServiceFactory::GetForProfile(profile_.get()); 84 SpellcheckServiceFactory::GetForProfile(profile_.get());
85 SpellcheckCustomDictionary* custom_dictionary = 85 SpellcheckCustomDictionary* custom_dictionary =
86 spellcheck_service->GetCustomDictionary(); 86 spellcheck_service->GetCustomDictionary();
87 87
88 WordList loaded_custom_words; 88 WordList loaded_custom_words;
89 custom_dictionary->LoadDictionaryIntoCustomWordList(&loaded_custom_words); 89 custom_dictionary->LoadDictionaryIntoCustomWordList(&loaded_custom_words);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 EXPECT_EQ(actual1, expected1); 145 EXPECT_EQ(actual1, expected1);
146 146
147 WordList actual2; 147 WordList actual2;
148 custom_dictionary2->LoadDictionaryIntoCustomWordList(&actual2); 148 custom_dictionary2->LoadDictionaryIntoCustomWordList(&actual2);
149 EXPECT_EQ(actual2, expected2); 149 EXPECT_EQ(actual2, expected2);
150 150
151 // Flush the loop now to prevent service init tasks from being run during 151 // Flush the loop now to prevent service init tasks from being run during
152 // TearDown(); 152 // TearDown();
153 MessageLoop::current()->RunUntilIdle(); 153 MessageLoop::current()->RunUntilIdle();
154 } 154 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698