| Index: chrome/browser/spellchecker/spellcheck_profile_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/spellchecker/spellcheck_profile_unittest.cc (revision 108048)
|
| +++ chrome/browser/spellchecker/spellcheck_profile_unittest.cc (working copy)
|
| @@ -34,14 +34,13 @@
|
| : SpellCheckProfile(profile_dir),
|
| create_host_calls_(0) {
|
| }
|
| -
|
| virtual SpellCheckHost* CreateHost(
|
| SpellCheckProfileProvider* profile,
|
| const std::string& language,
|
| net::URLRequestContextGetter* request_context,
|
| SpellCheckHostMetrics* metrics) {
|
| create_host_calls_++;
|
| - return returning_from_create_.get();
|
| + return returning_from_create_.release();
|
| }
|
|
|
| virtual bool IsTesting() const {
|
| @@ -49,17 +48,17 @@
|
| }
|
|
|
| bool IsCreatedHostReady() {
|
| - return GetHost() == returning_from_create_.get();
|
| + return !!GetHost();
|
| }
|
|
|
| void SetHostToBeCreated(MockSpellCheckHost* host) {
|
| EXPECT_CALL(*host, UnsetProfile()).Times(1);
|
| EXPECT_CALL(*host, IsReady()).WillRepeatedly(testing::Return(true));
|
| - returning_from_create_ = host;
|
| + returning_from_create_.reset(host);
|
| }
|
|
|
| size_t create_host_calls_;
|
| - scoped_refptr<SpellCheckHost> returning_from_create_;
|
| + scoped_ptr<SpellCheckHost> returning_from_create_;
|
| };
|
|
|
| typedef SpellCheckProfile::ReinitializeResult ResultType;
|
| @@ -76,11 +75,11 @@
|
| };
|
|
|
| TEST_F(SpellCheckProfileTest, ReinitializeEnabled) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
| - target.SetHostToBeCreated(host.get());
|
| + target.SetHostToBeCreated(host.release());
|
|
|
| // The first call should create host.
|
| ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
|
| @@ -99,12 +98,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, ReinitializeDisabled) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.returning_from_create_ = host.get();
|
| + target.returning_from_create_.reset(host.release());
|
|
|
| // If enabled is false, nothing should happen
|
| ResultType result1 = target.ReinitializeHost(false, false, "", NULL);
|
| @@ -118,12 +117,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, ReinitializeRemove) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.SetHostToBeCreated(host.get());
|
| + target.SetHostToBeCreated(host.release());
|
|
|
| // At first, create the host.
|
| ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
|
| @@ -139,12 +138,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, ReinitializeRecreate) {
|
| - scoped_refptr<MockSpellCheckHost> host1(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host1(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.SetHostToBeCreated(host1.get());
|
| + target.SetHostToBeCreated(host1.release());
|
|
|
| // At first, create the host.
|
| ResultType result1 = target.ReinitializeHost(false, true, "", NULL);
|
| @@ -154,8 +153,8 @@
|
| 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());
|
| + scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
|
| + target.SetHostToBeCreated(host2.release());
|
|
|
| ResultType result2 = target.ReinitializeHost(true, true, "", NULL);
|
| target.SpellCheckHostInitialized(0);
|
| @@ -165,12 +164,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, SpellCheckHostInitializedWithCustomWords) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.SetHostToBeCreated(host.get());
|
| + target.SetHostToBeCreated(host.release());
|
| target.ReinitializeHost(false, true, "", NULL);
|
|
|
| scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words
|
| @@ -183,12 +182,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, CustomWordAddedLocally) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.SetHostToBeCreated(host.get());
|
| + target.SetHostToBeCreated(host.release());
|
| target.ReinitializeHost(false, true, "", NULL);
|
|
|
| scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words
|
| @@ -205,12 +204,12 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, SaveAndLoad) {
|
| - scoped_refptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host(new MockSpellCheckHost());
|
| ScopedTempDir dir;
|
| ASSERT_TRUE(dir.CreateUniqueTempDir());
|
| TestingSpellCheckProfile target(dir.path());
|
|
|
| - target.SetHostToBeCreated(host.get());
|
| + target.SetHostToBeCreated(host.release());
|
| target.ReinitializeHost(false, true, "", NULL);
|
|
|
| scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words(
|
| @@ -233,9 +232,9 @@
|
|
|
| // Load in another instance of SpellCheckProfile.
|
| // The result should be the same.
|
| - scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
|
| TestingSpellCheckProfile target2(dir.path());
|
| - target2.SetHostToBeCreated(host2.get());
|
| + target2.SetHostToBeCreated(host2.release());
|
| target2.ReinitializeHost(false, true, "", NULL);
|
| scoped_ptr<SpellCheckProfile::CustomWordList> loaded_custom_words2(
|
| new SpellCheckProfile::CustomWordList());
|
| @@ -244,8 +243,8 @@
|
| }
|
|
|
| TEST_F(SpellCheckProfileTest, MultiProfile) {
|
| - scoped_refptr<MockSpellCheckHost> host1(new MockSpellCheckHost());
|
| - scoped_refptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host1(new MockSpellCheckHost());
|
| + scoped_ptr<MockSpellCheckHost> host2(new MockSpellCheckHost());
|
|
|
| ScopedTempDir dir1;
|
| ScopedTempDir dir2;
|
| @@ -254,9 +253,9 @@
|
| TestingSpellCheckProfile target1(dir1.path());
|
| TestingSpellCheckProfile target2(dir2.path());
|
|
|
| - target1.SetHostToBeCreated(host1.get());
|
| + target1.SetHostToBeCreated(host1.release());
|
| target1.ReinitializeHost(false, true, "", NULL);
|
| - target2.SetHostToBeCreated(host2.get());
|
| + target2.SetHostToBeCreated(host2.release());
|
| target2.ReinitializeHost(false, true, "", NULL);
|
|
|
| SpellCheckProfile::CustomWordList expected1;
|
|
|