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

Unified Diff: chrome/browser/download/download_request_limiter_unittest.cc

Issue 341833004: [WebsiteSettings] Enable permission bubbles by default. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 4 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/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();
« no previous file with comments | « chrome/browser/download/download_permission_request.cc ('k') | chrome/browser/geolocation/geolocation_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698