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

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: Exclude custom dictionary WebUI from mac 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 "chrome/browser/spellchecker/spellcheck_custom_dictionary.h" 7 #include "chrome/browser/spellchecker/spellcheck_custom_dictionary.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/common/spellcheck_common.h" 10 #include "chrome/common/spellcheck_common.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 SpellcheckService* spellcheck_service = 50 SpellcheckService* spellcheck_service =
51 SpellcheckServiceFactory::GetForProfile(profile_.get()); 51 SpellcheckServiceFactory::GetForProfile(profile_.get());
52 52
53 WordList loaded_custom_words; 53 WordList loaded_custom_words;
54 loaded_custom_words.push_back("foo"); 54 loaded_custom_words.push_back("foo");
55 loaded_custom_words.push_back("bar"); 55 loaded_custom_words.push_back("bar");
56 WordList expected(loaded_custom_words); 56 WordList expected(loaded_custom_words);
57 SpellcheckCustomDictionary* custom_dictionary = 57 SpellcheckCustomDictionary* custom_dictionary =
58 spellcheck_service->GetCustomDictionary(); 58 spellcheck_service->GetCustomDictionary();
59 custom_dictionary->SetCustomWordList(&loaded_custom_words); 59 custom_dictionary->SetCustomWordList(&loaded_custom_words);
60 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 60 EXPECT_EQ(custom_dictionary->GetWords(), expected);
61 } 61 }
62 62
63 TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) { 63 TEST_F(SpellcheckCustomDictionaryTest, CustomWordAddedLocally) {
64 SpellcheckService* spellcheck_service = 64 SpellcheckService* spellcheck_service =
65 SpellcheckServiceFactory::GetForProfile(profile_.get()); 65 SpellcheckServiceFactory::GetForProfile(profile_.get());
66 66
67 WordList loaded_custom_words; 67 WordList loaded_custom_words;
68 SpellcheckCustomDictionary* custom_dictionary = 68 SpellcheckCustomDictionary* custom_dictionary =
69 spellcheck_service->GetCustomDictionary(); 69 spellcheck_service->GetCustomDictionary();
70 custom_dictionary->Load(); 70 custom_dictionary->Load();
71 WordList expected; 71 WordList expected;
72 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 72 EXPECT_EQ(custom_dictionary->GetWords(), expected);
73 custom_dictionary->CustomWordAddedLocally("foo"); 73 custom_dictionary->CustomWordAddedLocally("foo");
74 expected.push_back("foo"); 74 expected.push_back("foo");
75 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 75 EXPECT_EQ(custom_dictionary->GetWords(), expected);
76 custom_dictionary->CustomWordAddedLocally("bar"); 76 custom_dictionary->CustomWordAddedLocally("bar");
77 expected.push_back("bar"); 77 expected.push_back("bar");
78 EXPECT_EQ(custom_dictionary->GetCustomWords(), expected); 78 EXPECT_EQ(custom_dictionary->GetWords(), expected);
79 } 79 }
80 80
81 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) { 81 TEST_F(SpellcheckCustomDictionaryTest, SaveAndLoad) {
82 SpellcheckService* spellcheck_service = 82 SpellcheckService* spellcheck_service =
83 SpellcheckServiceFactory::GetForProfile(profile_.get()); 83 SpellcheckServiceFactory::GetForProfile(profile_.get());
84 SpellcheckCustomDictionary* custom_dictionary = 84 SpellcheckCustomDictionary* custom_dictionary =
85 spellcheck_service->GetCustomDictionary(); 85 spellcheck_service->GetCustomDictionary();
86 86
87 WordList loaded_custom_words; 87 WordList loaded_custom_words;
88 custom_dictionary->LoadDictionaryIntoCustomWordList(&loaded_custom_words); 88 custom_dictionary->LoadDictionaryIntoCustomWordList(&loaded_custom_words);
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 EXPECT_EQ(actual1, expected1); 144 EXPECT_EQ(actual1, expected1);
145 145
146 WordList actual2; 146 WordList actual2;
147 custom_dictionary2->LoadDictionaryIntoCustomWordList(&actual2); 147 custom_dictionary2->LoadDictionaryIntoCustomWordList(&actual2);
148 EXPECT_EQ(actual2, expected2); 148 EXPECT_EQ(actual2, expected2);
149 149
150 // Flush the loop now to prevent service init tasks from being run during 150 // Flush the loop now to prevent service init tasks from being run during
151 // TearDown(); 151 // TearDown();
152 MessageLoop::current()->RunUntilIdle(); 152 MessageLoop::current()->RunUntilIdle();
153 } 153 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698