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

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

Issue 7919003: Remove refptr usages from SpellCheckHost (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: remove TODO comments 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 7efabd1773e60ceddf211ef11f6d6aa0ed59f790..cd53ef36262b0dc1f9692c84901d329d21f618bb 100644
--- a/chrome/browser/spellchecker/spellcheck_profile_unittest.cc
+++ b/chrome/browser/spellchecker/spellcheck_profile_unittest.cc
@@ -34,14 +34,13 @@ class TestingSpellCheckProfile : public SpellCheckProfile {
: 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 @@ class TestingSpellCheckProfile : public SpellCheckProfile {
}
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 @@ class SpellCheckProfileTest : public testing::Test {
};
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, ReinitializeEnabled) {
}
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, ReinitializeDisabled) {
}
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, ReinitializeRemove) {
}
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 @@ TEST_F(SpellCheckProfileTest, ReinitializeRecreate) {
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, ReinitializeRecreate) {
}
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, SpellCheckHostInitializedWithCustomWords) {
}
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, CustomWordAddedLocally) {
}
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 @@ TEST_F(SpellCheckProfileTest, SaveAndLoad) {
// 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, SaveAndLoad) {
}
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 @@ TEST_F(SpellCheckProfileTest, MultiProfile) {
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;

Powered by Google App Engine
This is Rietveld 408576698