diff options
author | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:56:38 +0000 |
---|---|---|
committer | jcampan@chromium.org <jcampan@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-02-17 20:56:38 +0000 |
commit | 00e70b534d98b39ee179f643a50d35698f58d5bf (patch) | |
tree | 7032d900a9677a9318933958aeaf90200abedf6a /chrome/browser/tab_contents/test_tab_contents.cc | |
parent | 7462646e2e740d7d5b1a848a524e6620047a6b34 (diff) | |
download | chromium_src-00e70b534d98b39ee179f643a50d35698f58d5bf.zip chromium_src-00e70b534d98b39ee179f643a50d35698f58d5bf.tar.gz chromium_src-00e70b534d98b39ee179f643a50d35698f58d5bf.tar.bz2 |
Calls InfoBarClosed on InfoBarDelegates in unit-tests to
ensure the InfoBarDelegates are not leaked.
BUG=35614
TEST=No leak in valgrind when running unit-tests.
Review URL: http://codereview.chromium.org/600157
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@39262 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/tab_contents/test_tab_contents.cc')
-rw-r--r-- | chrome/browser/tab_contents/test_tab_contents.cc | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/chrome/browser/tab_contents/test_tab_contents.cc b/chrome/browser/tab_contents/test_tab_contents.cc index bd5eac4..84bde21 100644 --- a/chrome/browser/tab_contents/test_tab_contents.cc +++ b/chrome/browser/tab_contents/test_tab_contents.cc @@ -6,10 +6,39 @@ #include "chrome/browser/renderer_host/render_view_host.h" #include "chrome/browser/renderer_host/test/test_render_view_host.h" +#include "chrome/common/notification_service.h" TestTabContents::TestTabContents(Profile* profile, SiteInstance* instance) : TabContents(profile, instance, MSG_ROUTING_NONE, NULL), transition_cross_site(false) { + // Listen for infobar events so we can call InfoBarClosed() on the infobar + // delegates and give them an opportunity to delete themselves. (Since we + // have no InfobarContainer in TestTabContents, InfoBarClosed() is not called + // most likely leading to the infobar delegates being leaked.) + Source<TabContents> source(this); + registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REMOVED, + source); + registrar_.Add(this, NotificationType::TAB_CONTENTS_INFOBAR_REPLACED, + source); +} + +void TestTabContents::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + // TabContents does not handle TAB_CONTENTS_INFOBAR_* so we don't pass it + // these notifications. + switch (type.value) { + case NotificationType::TAB_CONTENTS_INFOBAR_REMOVED: + Details<InfoBarDelegate>(details).ptr()->InfoBarClosed(); + break; + case NotificationType::TAB_CONTENTS_INFOBAR_REPLACED: + Details<std::pair<InfoBarDelegate*, InfoBarDelegate*> >(details).ptr()-> + first->InfoBarClosed(); + break; + default: + TabContents::Observe(type, source, details); + break; + } } TestRenderViewHost* TestTabContents::pending_rvh() { |