| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/download/download_request_limiter.h" | 5 #include "chrome/browser/download/download_request_limiter.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/run_loop.h" | 8 #include "base/run_loop.h" |
| 9 #include "chrome/browser/download/download_request_infobar_delegate.h" | 9 #include "chrome/browser/download/download_request_infobar_delegate.h" |
| 10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 53 }; | 53 }; |
| 54 | 54 |
| 55 class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { | 55 class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
| 56 public: | 56 public: |
| 57 enum TestingAction { | 57 enum TestingAction { |
| 58 ACCEPT, | 58 ACCEPT, |
| 59 CANCEL, | 59 CANCEL, |
| 60 WAIT | 60 WAIT |
| 61 }; | 61 }; |
| 62 | 62 |
| 63 virtual void SetUp() { | 63 void SetUp() override { |
| 64 ChromeRenderViewHostTestHarness::SetUp(); | 64 ChromeRenderViewHostTestHarness::SetUp(); |
| 65 InfoBarService::CreateForWebContents(web_contents()); | 65 InfoBarService::CreateForWebContents(web_contents()); |
| 66 | 66 |
| 67 PermissionBubbleManager::CreateForWebContents(web_contents()); | 67 PermissionBubbleManager::CreateForWebContents(web_contents()); |
| 68 view_.reset(new FakePermissionBubbleView(this)); | 68 view_.reset(new FakePermissionBubbleView(this)); |
| 69 PermissionBubbleManager* manager = | 69 PermissionBubbleManager* manager = |
| 70 PermissionBubbleManager::FromWebContents(web_contents()); | 70 PermissionBubbleManager::FromWebContents(web_contents()); |
| 71 manager->SetView(view_.get()); | 71 manager->SetView(view_.get()); |
| 72 | 72 |
| 73 testing_action_ = ACCEPT; | 73 testing_action_ = ACCEPT; |
| (...skipping 25 matching lines...) Expand all Loading... |
| 99 host->Accept(); | 99 host->Accept(); |
| 100 break; | 100 break; |
| 101 case CANCEL: | 101 case CANCEL: |
| 102 host->Cancel(); | 102 host->Cancel(); |
| 103 break; | 103 break; |
| 104 case WAIT: | 104 case WAIT: |
| 105 break; | 105 break; |
| 106 } | 106 } |
| 107 } | 107 } |
| 108 | 108 |
| 109 virtual void TearDown() { | 109 void TearDown() override { |
| 110 content_settings_->ShutdownOnUIThread(); | 110 content_settings_->ShutdownOnUIThread(); |
| 111 content_settings_ = NULL; | 111 content_settings_ = NULL; |
| 112 UnsetDelegate(); | 112 UnsetDelegate(); |
| 113 ChromeRenderViewHostTestHarness::TearDown(); | 113 ChromeRenderViewHostTestHarness::TearDown(); |
| 114 } | 114 } |
| 115 | 115 |
| 116 virtual void UnsetDelegate() { | 116 virtual void UnsetDelegate() { |
| 117 DownloadRequestInfoBarDelegate::SetCallbackForTesting(NULL); | 117 DownloadRequestInfoBarDelegate::SetCallbackForTesting(NULL); |
| 118 } | 118 } |
| 119 | 119 |
| (...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 451 CanDownload(); | 451 CanDownload(); |
| 452 ExpectAndResetCounts(0, 1, 0, __LINE__); | 452 ExpectAndResetCounts(0, 1, 0, __LINE__); |
| 453 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 453 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 454 download_request_limiter_->GetDownloadStatus(web_contents())); | 454 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 455 | 455 |
| 456 CanDownload(); | 456 CanDownload(); |
| 457 ExpectAndResetCounts(0, 1, 0, __LINE__); | 457 ExpectAndResetCounts(0, 1, 0, __LINE__); |
| 458 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, | 458 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| 459 download_request_limiter_->GetDownloadStatus(web_contents())); | 459 download_request_limiter_->GetDownloadStatus(web_contents())); |
| 460 } | 460 } |
| OLD | NEW |