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

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: 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..8497c3b9dc7a3589b866b8abca43249ac9fa6a69 100644
--- a/components/dom_distiller/core/distilled_page_prefs_unittests.cc
+++ b/components/dom_distiller/core/distilled_page_prefs_unittests.cc
@@ -32,44 +32,44 @@ 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<DistilledPagePrefs> distilled_page_prefs_;
nyquist 2014/07/16 16:10:53 I think the ordering of these two needs to be swap
smaslo 2014/07/16 16:12:51 Done.
+ scoped_ptr<user_prefs::TestingPrefServiceSyncable> pref_service_;
private:
base::MessageLoop message_loop_;
};
TEST_F(DistilledPagePrefsTest, TestingOnChangeThemeIsBeingCalled) {
- TestingObserver* obs = new TestingObserver();
- distilled_page_prefs_->AddObserver(obs);
+ TestingObserver obs;
nyquist 2014/07/16 16:02:57 Remove this as an observer here and in the test be
smaslo 2014/07/16 16:06:50 Done.
+ 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());
}
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());
}
} // 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