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

Unified Diff: chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc

Issue 9491009: Show queued geolocation InfoBars when InfoBar is hidden. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix memory leak in TabDestroyed unit test, suppress gtk memory leak. Created 8 years, 9 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/geolocation/chrome_geolocation_permission_context_unittest.cc
diff --git a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
index cd583458772eafeae3d2cf0a03beb2ac66ab137a..f542e9b0f3fdc395c2f52d1b0756b843cff8c89d 100644
--- a/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
+++ b/chrome/browser/geolocation/chrome_geolocation_permission_context_unittest.cc
@@ -40,6 +40,7 @@ namespace {
// We need to track which infobars were closed.
class ClosedDelegateTracker : public content::NotificationObserver {
+ FRIEND_TEST_ALL_PREFIXES(GeolocationPermissionContextTests, TabDestroyed);
Peter Kasting 2012/03/26 19:12:22 This doesn't go above the public section, it goes
John Knottenbelt 2012/03/27 10:21:29 Done.
public:
ClosedDelegateTracker();
virtual ~ClosedDelegateTracker();
@@ -86,9 +87,6 @@ void ClosedDelegateTracker::Clear() {
removed_infobar_delegates_.clear();
}
-} // namespace
-
-
// GeolocationPermissionContextTests ------------------------------------------
// This class sets up GeolocationArbitrator.
@@ -139,8 +137,8 @@ class GeolocationPermissionContextTests : public TabContentsWrapperTestHarness {
private:
// TabContentsWrapperTestHarness:
- virtual void SetUp();
- virtual void TearDown();
+ virtual void SetUp() OVERRIDE;
+ virtual void TearDown() OVERRIDE;
content::TestBrowserThread ui_thread_;
content::MockGeolocation mock_geolocation_;
@@ -239,6 +237,7 @@ void GeolocationPermissionContextTests::SetUp() {
}
void GeolocationPermissionContextTests::TearDown() {
+ extra_tabs_.reset();
mock_geolocation_.TearDown();
TabContentsWrapperTestHarness::TearDown();
}
@@ -471,8 +470,6 @@ TEST_F(GeolocationPermissionContextTests, SameOriginMultipleTabs) {
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
infobar_1->InfoBarClosed();
-
- extra_tabs_.reset();
}
TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
@@ -528,8 +525,6 @@ TEST_F(GeolocationPermissionContextTests, QueuedOriginMultipleTabs) {
EXPECT_EQ(1U, closed_delegate_tracker_.size());
EXPECT_TRUE(closed_delegate_tracker_.Contains(infobar_1));
infobar_1->InfoBarClosed();
-
- extra_tabs_.reset();
}
TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
@@ -567,6 +562,16 @@ TEST_F(GeolocationPermissionContextTests, TabDestroyed) {
// Delete the tab contents.
DeleteContents();
infobar_0->InfoBarClosed();
+
+ // During contents destruction, the infobar will have been closed, and a
+ // second (with it's own new delegate) will have been created. In Chromium,
+ // this would be properly deleted by the InfoBarContainer, but in this unit
+ // test, the closest thing we have to that is the ClosedDelegateTracker.
+ ASSERT_EQ(2U, closed_delegate_tracker_.size());
+ ASSERT_TRUE(closed_delegate_tracker_.Contains(infobar_0));
+ closed_delegate_tracker_.removed_infobar_delegates_.erase(infobar_0);
+ (*closed_delegate_tracker_.removed_infobar_delegates_.begin())->
+ InfoBarClosed();
}
TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) {
@@ -598,3 +603,5 @@ TEST_F(GeolocationPermissionContextTests, InfoBarUsesCommittedEntry) {
DeleteContents();
infobar_0->InfoBarClosed();
}
+
+} // namespace
Peter Kasting 2012/03/26 19:12:22 Don't extend the namespace to cover the unit tests
John Knottenbelt 2012/03/27 10:21:29 I removed the namespace. The issue is that the FRI
« no previous file with comments | « chrome/browser/geolocation/chrome_geolocation_permission_context.cc ('k') | tools/valgrind/memcheck/suppressions.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698