Index: chrome/browser/download/download_request_limiter_unittest.cc |
diff --git a/chrome/browser/download/download_request_limiter_unittest.cc b/chrome/browser/download/download_request_limiter_unittest.cc |
index 0619044d537fadf1b322798e14d75892a5aaac27..5cf43ff119c91674d16f7c4657e72f5d2fded47d 100644 |
--- a/chrome/browser/download/download_request_limiter_unittest.cc |
+++ b/chrome/browser/download/download_request_limiter_unittest.cc |
@@ -181,6 +181,11 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
setting); |
} |
+ void BubbleManagerDocumentLoadCompleted() { |
+ PermissionBubbleManager::FromWebContents(web_contents())-> |
+ DocumentOnLoadCompletedInMainFrame(); |
+ } |
+ |
scoped_refptr<DownloadRequestLimiter> download_request_limiter_; |
// The action that FakeCreate() should take. |
@@ -210,8 +215,10 @@ void FakePermissionBubbleView::Show( |
test_->AskAllow(); |
int action = test_->GetAction(); |
if (action == DownloadRequestLimiterTest::ACCEPT) { |
+LOG(INFO) << "Test: accept"; |
delegate_->Accept(); |
} else if (action == DownloadRequestLimiterTest::CANCEL) { |
+LOG(INFO) << "Test: deny"; |
delegate_->Deny(); |
} else if (action == DownloadRequestLimiterTest::WAIT) { |
// do nothing. |
@@ -222,6 +229,8 @@ void FakePermissionBubbleView::Show( |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_Allow) { |
+ BubbleManagerDocumentLoadCompleted(); |
+ |
// All tabs should initially start at ALLOW_ONE_DOWNLOAD. |
ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
@@ -254,6 +263,7 @@ TEST_F(DownloadRequestLimiterTest, |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_ResetOnNavigation) { |
NavigateAndCommit(GURL("http://foo.com/bar")); |
+ BubbleManagerDocumentLoadCompleted(); |
// Do two downloads, allowing the second so that we end up with allow all. |
CanDownload(); |
@@ -270,6 +280,7 @@ TEST_F(DownloadRequestLimiterTest, |
// Navigate to a new URL with the same host, which shouldn't reset the allow |
// all state. |
NavigateAndCommit(GURL("http://foo.com/bar2")); |
+ BubbleManagerDocumentLoadCompleted(); |
CanDownload(); |
ExpectAndResetCounts(1, 0, 0, __LINE__); |
ASSERT_EQ(DownloadRequestLimiter::ALLOW_ALL_DOWNLOADS, |
@@ -283,6 +294,7 @@ TEST_F(DownloadRequestLimiterTest, |
// Navigate to a completely different host, which should reset the state. |
NavigateAndCommit(GURL("http://fooey.com")); |
+ BubbleManagerDocumentLoadCompleted(); |
ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
@@ -301,6 +313,7 @@ TEST_F(DownloadRequestLimiterTest, |
// Navigate to a new URL with the same host, which shouldn't reset the allow |
// all state. |
NavigateAndCommit(GURL("http://fooey.com/bar2")); |
+ BubbleManagerDocumentLoadCompleted(); |
CanDownload(); |
ExpectAndResetCounts(0, 1, 0, __LINE__); |
ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, |
@@ -310,6 +323,7 @@ TEST_F(DownloadRequestLimiterTest, |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_ResetOnUserGesture) { |
NavigateAndCommit(GURL("http://foo.com/bar")); |
+ BubbleManagerDocumentLoadCompleted(); |
// Do one download, which should change to prompt before download. |
CanDownload(); |
@@ -350,6 +364,7 @@ TEST_F(DownloadRequestLimiterTest, |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_ResetOnReload) { |
NavigateAndCommit(GURL("http://foo.com/bar")); |
+ BubbleManagerDocumentLoadCompleted(); |
ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
download_request_limiter_->GetDownloadStatus(web_contents())); |
@@ -437,6 +452,7 @@ TEST_F(DownloadRequestLimiterTest, |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_SetHostContentSetting) { |
NavigateAndCommit(GURL("http://foo.com/bar")); |
+ BubbleManagerDocumentLoadCompleted(); |
SetHostContentSetting(web_contents(), CONTENT_SETTING_ALLOW); |
CanDownload(); |