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

Unified Diff: chrome/browser/ui/website_settings/website_settings_unittest.cc

Issue 10837049: Fix memory leak in WebsiteSettingsTest.ShowInfoBar. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Delete InfoBarDelegate via InfoBarClosed() method. Created 8 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 | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/website_settings/website_settings_unittest.cc
diff --git a/chrome/browser/ui/website_settings/website_settings_unittest.cc b/chrome/browser/ui/website_settings/website_settings_unittest.cc
index c1649f10629c6632a6b6c57a463237e98c74c007..02f0724d95331510f0292f3f250b814a0fcf672a 100644
--- a/chrome/browser/ui/website_settings/website_settings_unittest.cc
+++ b/chrome/browser/ui/website_settings/website_settings_unittest.cc
@@ -10,6 +10,7 @@
#include "base/utf_string_conversions.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
#include "chrome/browser/content_settings/tab_specific_content_settings.h"
+#include "chrome/browser/infobars/infobar_delegate.h"
#include "chrome/browser/infobars/infobar_tab_helper.h"
#include "chrome/browser/ui/website_settings/website_settings_ui.h"
#include "chrome/common/content_settings.h"
@@ -341,6 +342,14 @@ TEST_F(WebsiteSettingsTest, ShowInfoBar) {
website_settings()->OnUIClosing();
EXPECT_EQ(1u, infobar_tab_helper()->infobar_count());
- infobar_tab_helper()->RemoveInfoBar(
+ // Removing an |InfoBarDelegate| from the |InfoBarTabHelper| does not delete
+ // it. Hence the |delegate| must be cleaned up after it was removed from the
+ // |infobar_tab_helper|.
+ scoped_ptr<InfoBarDelegate> delegate(
infobar_tab_helper()->GetInfoBarDelegateAt(0));
+ infobar_tab_helper()->RemoveInfoBar(delegate.get());
+ // Right now InfoBarDelegates delete themselves via
+ // InfoBarClosed(); once InfoBars own their delegates, this can become a
+ // simple reset() call
+ delegate.release()->InfoBarClosed();
}
« no previous file with comments | « no previous file | tools/heapcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698