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

Unified Diff: chrome/browser/google/google_url_tracker_unittest.cc

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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/google/google_url_tracker_unittest.cc
===================================================================
--- chrome/browser/google/google_url_tracker_unittest.cc (revision 175396)
+++ chrome/browser/google/google_url_tracker_unittest.cc (working copy)
@@ -31,13 +31,25 @@
class TestInfoBarDelegate : public GoogleURLTrackerInfoBarDelegate {
public:
+ // Creates a test delegate and returns it. Unlike the parent class, this does
+ // not create add the infobar to |infobar_service|, since that "pointer" is
+ // really just a magic number. Thus there is no InfoBarService ownership of
+ // the returned object; and since the caller doesn't own the returned object,
+ // we rely on |test_harness| cleaning this up eventually in
+ // GoogleURLTrackerTest::OnInfoBarClosed() to avoid leaks.
+ static GoogleURLTrackerInfoBarDelegate* Create(
+ GoogleURLTrackerTest* test_harness,
+ InfoBarService* infobar_service,
+ GoogleURLTracker* google_url_tracker,
+ const GURL& search_url);
+
+ private:
TestInfoBarDelegate(GoogleURLTrackerTest* test_harness,
InfoBarService* infobar_service,
GoogleURLTracker* google_url_tracker,
const GURL& search_url);
virtual ~TestInfoBarDelegate();
- private:
// GoogleURLTrackerInfoBarDelegate:
virtual void Update(const GURL& search_url) OVERRIDE;
virtual void Close(bool redo_search) OVERRIDE;
@@ -106,7 +118,7 @@
class GoogleURLTrackerTest : public testing::Test {
public:
// Called by TestInfoBarDelegate::Close().
- void OnInfoBarClosed(GoogleURLTrackerInfoBarDelegate* infobar,
+ void OnInfoBarClosed(InfoBarDelegate* infobar,
InfoBarService* infobar_service);
protected:
@@ -170,9 +182,8 @@
std::set<int> unique_ids_seen_;
};
-void GoogleURLTrackerTest::OnInfoBarClosed(
- GoogleURLTrackerInfoBarDelegate* infobar,
- InfoBarService* infobar_service) {
+void GoogleURLTrackerTest::OnInfoBarClosed(InfoBarDelegate* infobar,
+ InfoBarService* infobar_service) {
// First, simulate the InfoBarService firing INFOBAR_REMOVED.
InfoBarRemovedDetails removed_details(infobar, false);
GoogleURLTracker::EntryMap::const_iterator i =
@@ -185,7 +196,7 @@
content::Details<InfoBarRemovedDetails>(&removed_details));
// Second, simulate the infobar container closing the infobar in response.
- infobar->InfoBarClosed();
+ delete infobar;
}
GoogleURLTrackerTest::GoogleURLTrackerTest()
@@ -386,8 +397,8 @@
InfoBarService* infobar_service,
GoogleURLTracker* google_url_tracker,
const GURL& search_url) {
- return new TestInfoBarDelegate(this, infobar_service, google_url_tracker,
- search_url);
+ return TestInfoBarDelegate::Create(this, infobar_service, google_url_tracker,
+ search_url);
}
@@ -395,6 +406,16 @@
namespace {
+// static
+GoogleURLTrackerInfoBarDelegate* TestInfoBarDelegate::Create(
+ GoogleURLTrackerTest* test_harness,
+ InfoBarService* infobar_service,
+ GoogleURLTracker* google_url_tracker,
+ const GURL& search_url) {
+ return new TestInfoBarDelegate(test_harness, infobar_service,
+ google_url_tracker, search_url);
+}
+
TestInfoBarDelegate::TestInfoBarDelegate(GoogleURLTrackerTest* test_harness,
InfoBarService* infobar_service,
GoogleURLTracker* google_url_tracker,
« no previous file with comments | « chrome/browser/google/google_url_tracker_infobar_delegate.cc ('k') | chrome/browser/infobars/alternate_nav_infobar_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698