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

Unified Diff: components/dom_distiller/core/distilled_page_prefs_unittests.cc

Issue 394973004: Fixing memory leak in DistilledPagePrefs unittests (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Switching order Created 6 years, 5 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/dom_distiller/core/distilled_page_prefs_unittests.cc
diff --git a/components/dom_distiller/core/distilled_page_prefs_unittests.cc b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
index 1c2ccf8e1729d6d63a4ba15f50cc7fe859bafeca..700a9fcf089fbebc3a5f1a449dfa46af146e21e5 100644
--- a/components/dom_distiller/core/distilled_page_prefs_unittests.cc
+++ b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
@@ -32,44 +32,46 @@ class TestingObserver : public DistilledPagePrefs::Observer {
class DistilledPagePrefsTest : public testing::Test {
protected:
virtual void SetUp() OVERRIDE {
- user_prefs::TestingPrefServiceSyncable* pref_service =
- new user_prefs::TestingPrefServiceSyncable();
- DistilledPagePrefs::RegisterProfilePrefs(pref_service->registry());
- distilled_page_prefs_ = new DistilledPagePrefs(pref_service);
+ pref_service_.reset(new user_prefs::TestingPrefServiceSyncable());
+ DistilledPagePrefs::RegisterProfilePrefs(pref_service_->registry());
+ distilled_page_prefs_.reset(new DistilledPagePrefs(pref_service_.get()));
}
- DistilledPagePrefs* distilled_page_prefs_;
+ scoped_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
+ scoped_ptr<DistilledPagePrefs> distilled_page_prefs_;
private:
base::MessageLoop message_loop_;
};
TEST_F(DistilledPagePrefsTest, TestingOnChangeThemeIsBeingCalled) {
- TestingObserver* obs = new TestingObserver();
- distilled_page_prefs_->AddObserver(obs);
+ TestingObserver obs;
+ distilled_page_prefs_->AddObserver(&obs);
distilled_page_prefs_->SetTheme(DistilledPagePrefs::SEPIA);
- EXPECT_EQ(DistilledPagePrefs::LIGHT, obs->GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::LIGHT, obs.GetTheme());
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(DistilledPagePrefs::SEPIA, obs->GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::SEPIA, obs.GetTheme());
distilled_page_prefs_->SetTheme(DistilledPagePrefs::DARK);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(DistilledPagePrefs::DARK, obs->GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::DARK, obs.GetTheme());
+ distilled_page_prefs_->RemoveObserver(&obs);
}
TEST_F(DistilledPagePrefsTest, TestingMultipleObservers) {
- TestingObserver* obs = new TestingObserver();
- distilled_page_prefs_->AddObserver(obs);
- TestingObserver* obs2 = new TestingObserver();
- distilled_page_prefs_->AddObserver(obs2);
+ TestingObserver obs;
+ distilled_page_prefs_->AddObserver(&obs);
+ TestingObserver obs2;
+ distilled_page_prefs_->AddObserver(&obs2);
distilled_page_prefs_->SetTheme(DistilledPagePrefs::SEPIA);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(DistilledPagePrefs::SEPIA, obs->GetTheme());
- EXPECT_EQ(DistilledPagePrefs::SEPIA, obs2->GetTheme());
- distilled_page_prefs_->RemoveObserver(obs);
+ EXPECT_EQ(DistilledPagePrefs::SEPIA, obs.GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::SEPIA, obs2.GetTheme());
+ distilled_page_prefs_->RemoveObserver(&obs);
distilled_page_prefs_->SetTheme(DistilledPagePrefs::LIGHT);
base::RunLoop().RunUntilIdle();
- EXPECT_EQ(DistilledPagePrefs::SEPIA, obs->GetTheme());
- EXPECT_EQ(DistilledPagePrefs::LIGHT, obs2->GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::SEPIA, obs.GetTheme());
+ EXPECT_EQ(DistilledPagePrefs::LIGHT, obs2.GetTheme());
+ distilled_page_prefs_->RemoveObserver(&obs2);
}
} // namespace dom_distiller
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698