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

Unified Diff: chrome/browser/spellchecker/spellcheck_profile_unittest.cc

Issue 8233040: SpellCheck refactoring: Moved user custom dictionary for spell check to SpellCheckProfile. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Created 9 years, 2 months 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/spellchecker/spellcheck_profile_unittest.cc
diff --git a/chrome/browser/spellchecker/spellcheck_profile_unittest.cc b/chrome/browser/spellchecker/spellcheck_profile_unittest.cc
index 4e03fa9160c5226d58c6166a7b2b9ffd16c32109..711beb24560b963539af96756249df0896f41066 100644
--- a/chrome/browser/spellchecker/spellcheck_profile_unittest.cc
+++ b/chrome/browser/spellchecker/spellcheck_profile_unittest.cc
@@ -56,6 +56,14 @@ class TestingSpellCheckProfile : public SpellCheckProfile {
returning_from_create_ = host;
}
+ void LoadCustomDictionary() {
+ // Do nothing.
+ }
+
+ void WriteWordToCustomDictionary(const std::string& word) {
+ // Do nothing.
+ }
+
size_t create_host_calls_;
scoped_refptr<SpellCheckHost> returning_from_create_;
};
@@ -75,113 +83,102 @@ class SpellCheckProfileTest : public testing::Test {
TEST_F(SpellCheckProfileTest, ReinitializeEnabled) {
scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.SetHostToBeCreated(host.get());
+ scoped_refptr<TestingSpellCheckProfile> target(
+ new TestingSpellCheckProfile());
+ target->SetHostToBeCreated(host.get());
// The first call should create host.
- ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
- EXPECT_EQ(target.create_host_calls_, 1U);
+ ResultType result1 = target->ReinitializeHost(false, true, "", NULL);
+ EXPECT_EQ(target->create_host_calls_, 1U);
EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST);
// The second call should be ignored.
- ResultType result2 = target.ReinitializeHost(false, true, "", NULL);
+ ResultType result2 = target->ReinitializeHost(false, true, "", NULL);
EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING);
- EXPECT_EQ(target.create_host_calls_, 1U);
+ EXPECT_EQ(target->create_host_calls_, 1U);
// Host should become ready after the notification.
- EXPECT_FALSE(target.IsCreatedHostReady());
- target.SpellCheckHostInitialized(0);
- EXPECT_TRUE(target.IsCreatedHostReady());
+ EXPECT_FALSE(target->IsCreatedHostReady());
+ target->SpellCheckHostInitialized();
+ EXPECT_TRUE(target->IsCreatedHostReady());
}
TEST_F(SpellCheckProfileTest, ReinitializeDisabled) {
scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.returning_from_create_ = host.get();
+ scoped_refptr<TestingSpellCheckProfile> target(
+ new TestingSpellCheckProfile());
+ target->returning_from_create_ = host.get();
// If enabled is false, nothing should happen
- ResultType result1 = target.ReinitializeHost(false, false, "", NULL);
- EXPECT_EQ(target.create_host_calls_, 0U);
+ ResultType result1 = target->ReinitializeHost(false, false, "", NULL);
+ EXPECT_EQ(target->create_host_calls_, 0U);
EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_DID_NOTHING);
// Nothing should happen even if forced.
- ResultType result2 = target.ReinitializeHost(true, false, "", NULL);
- EXPECT_EQ(target.create_host_calls_, 0U);
+ ResultType result2 = target->ReinitializeHost(true, false, "", NULL);
+ EXPECT_EQ(target->create_host_calls_, 0U);
EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_DID_NOTHING);
}
TEST_F(SpellCheckProfileTest, ReinitializeRemove) {
scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.SetHostToBeCreated(host.get());
-
+ scoped_refptr<TestingSpellCheckProfile> target(
+ new TestingSpellCheckProfile());
+ target->SetHostToBeCreated(host.get());
// At first, create the host.
- ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
- target.SpellCheckHostInitialized(0);
+ ResultType result1 = target->ReinitializeHost(false, true, "", NULL);
+ target->SpellCheckHostInitialized();
EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST);
- EXPECT_TRUE(target.IsCreatedHostReady());
+ EXPECT_TRUE(target->IsCreatedHostReady());
// Then the host should be deleted if it's forced to be disabled.
- ResultType result2 = target.ReinitializeHost(true, false, "", NULL);
- target.SpellCheckHostInitialized(0);
+ ResultType result2 = target->ReinitializeHost(true, false, "", NULL);
+ target->SpellCheckHostInitialized();
EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_REMOVED_HOST);
- EXPECT_FALSE(target.IsCreatedHostReady());
+ EXPECT_FALSE(target->IsCreatedHostReady());
}
TEST_F(SpellCheckProfileTest, ReinitializeRecreate) {
scoped_refptr<MockSpellCheckHost> host1(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.SetHostToBeCreated(host1.get());
+ scoped_refptr<TestingSpellCheckProfile> target(
+ new TestingSpellCheckProfile());
+ target->SetHostToBeCreated(host1.get());
// At first, create the host.
- ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
- target.SpellCheckHostInitialized(0);
- EXPECT_EQ(target.create_host_calls_, 1U);
+ ResultType result1 = target->ReinitializeHost(false, true, "", NULL);
+ target->SpellCheckHostInitialized();
+ EXPECT_EQ(target->create_host_calls_, 1U);
EXPECT_EQ(result1, SpellCheckProfile::REINITIALIZE_CREATED_HOST);
- EXPECT_TRUE(target.IsCreatedHostReady());
+ EXPECT_TRUE(target->IsCreatedHostReady());
// Then the host should be re-created if it's forced to recreate.
scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
- target.SetHostToBeCreated(host2.get());
+ target->SetHostToBeCreated(host2.get());
- ResultType result2 = target.ReinitializeHost(true, true, "", NULL);
- target.SpellCheckHostInitialized(0);
- EXPECT_EQ(target.create_host_calls_, 2U);
+ ResultType result2 = target->ReinitializeHost(true, true, "", NULL);
+ target->SpellCheckHostInitialized();
+ EXPECT_EQ(target->create_host_calls_, 2U);
EXPECT_EQ(result2, SpellCheckProfile::REINITIALIZE_CREATED_HOST);
- EXPECT_TRUE(target.IsCreatedHostReady());
-}
-
-TEST_F(SpellCheckProfileTest, SpellCheckHostInitializedWithCustomWords) {
Hironori Bono 2011/10/12 02:56:56 I'm wondering why this change deletes this test. (
shinyak (Google) 2011/10/12 10:46:54 Done.
- scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.SetHostToBeCreated(host.get());
- target.ReinitializeHost(false, true, "", NULL);
-
- scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words
- (new SpellCheckProfile::CustomWordList());
- loaded_custom_words->push_back("foo");
- loaded_custom_words->push_back("bar");
- SpellCheckProfile::CustomWordList expected(*loaded_custom_words);
- target.SpellCheckHostInitialized(loaded_custom_words.release());
- EXPECT_EQ(target.GetCustomWords(), expected);
+ EXPECT_TRUE(target->IsCreatedHostReady());
}
TEST_F(SpellCheckProfileTest, CustomWordAddedLocally) {
scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
- TestingSpellCheckProfile target;
- target.SetHostToBeCreated(host.get());
- target.ReinitializeHost(false, true, "", NULL);
+ scoped_refptr<TestingSpellCheckProfile> target(
+ new TestingSpellCheckProfile());
+ target->SetHostToBeCreated(host.get());
+ target->ReinitializeHost(false, true, "", NULL);
scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words
(new SpellCheckProfile::CustomWordList());
- target.SpellCheckHostInitialized(NULL);
+ target->SpellCheckHostInitialized();
SpellCheckProfile::CustomWordList expected;
- EXPECT_EQ(target.GetCustomWords(), expected);
- target.CustomWordAddedLocally("foo");
+ EXPECT_EQ(target->GetCustomWords(), expected);
+ target->CustomWordAddedLocally("foo");
expected.push_back("foo");
- EXPECT_EQ(target.GetCustomWords(), expected);
- target.CustomWordAddedLocally("bar");
+ EXPECT_EQ(target->GetCustomWords(), expected);
+ target->CustomWordAddedLocally("bar");
expected.push_back("bar");
- EXPECT_EQ(target.GetCustomWords(), expected);
+ EXPECT_EQ(target->GetCustomWords(), expected);
}

Powered by Google App Engine
This is Rietveld 408576698