Chromium Code Reviews| 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 fafb6139a735323d57d38e45104c07e95dbc6049..d084be6b64b52612bb9c5f78a76a1f6b05432a77 100644 |
| --- a/chrome/browser/download/download_request_limiter_unittest.cc |
| +++ b/chrome/browser/download/download_request_limiter_unittest.cc |
| @@ -23,14 +23,9 @@ |
| #include "content/public/test/web_contents_tester.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -#if defined(OS_ANDROID) |
| -#include "chrome/browser/download/download_request_infobar_delegate_android.h" |
| -#include "chrome/browser/infobars/infobar_service.h" |
| -#else |
| #include "chrome/browser/download/download_permission_request.h" |
| #include "chrome/browser/permissions/permission_request_manager.h" |
| #include "chrome/browser/ui/permission_bubble/mock_permission_prompt_factory.h" |
| -#endif |
| using content::WebContents; |
| @@ -41,61 +36,6 @@ enum TestingAction { |
| WAIT |
| }; |
| -#if defined(OS_ANDROID) |
| -class TestingDelegate { |
| - public: |
| - void SetUp(WebContents* web_contents) { |
| - InfoBarService::CreateForWebContents(web_contents); |
| - fake_create_callback_ = |
| - base::Bind(&TestingDelegate::FakeCreate, base::Unretained(this)); |
| - DownloadRequestInfoBarDelegateAndroid::SetCallbackForTesting( |
| - &fake_create_callback_); |
| - ResetCounts(); |
|
raymes
2017/06/20 04:13:46
I think we should just put if (PermissionRequestMa
|
| - } |
| - |
| - void TearDown() { UnsetInfobarDelegate(); } |
| - |
| - void LoadCompleted(WebContents* /*web_contents*/) { |
| - // No action needed on OS_ANDROID. |
| - } |
| - |
| - void ResetCounts() { ask_allow_count_ = 0; } |
| - |
| - int AllowCount() { return ask_allow_count_; } |
| - |
| - void UpdateExpectations(TestingAction action) { testing_action_ = action; } |
| - |
| - void FakeCreate( |
| - InfoBarService* infobar_service, |
| - base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) { |
| - ask_allow_count_++; |
| - switch (testing_action_) { |
| - case ACCEPT: |
| - host->Accept(); |
| - break; |
| - case CANCEL: |
| - host->Cancel(); |
| - break; |
| - case WAIT: |
| - break; |
| - } |
| - } |
| - |
| - void UnsetInfobarDelegate() { |
| - DownloadRequestInfoBarDelegateAndroid::SetCallbackForTesting(nullptr); |
| - } |
| - |
| - private: |
| - // Number of times ShouldAllowDownload was invoked. |
| - int ask_allow_count_; |
| - |
| - // The action that FakeCreate() should take. |
| - TestingAction testing_action_; |
| - |
| - DownloadRequestInfoBarDelegateAndroid::FakeCreateCallback |
| - fake_create_callback_; |
| -}; |
| -#else |
| class TestingDelegate { |
| public: |
| void SetUp(WebContents* web_contents) { |
| @@ -137,7 +77,6 @@ class TestingDelegate { |
| private: |
| std::unique_ptr<MockPermissionPromptFactory> mock_permission_prompt_factory_; |
| }; |
| -#endif |
| } // namespace |
| class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
| @@ -571,7 +510,6 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_ResetOnReload) { |
| download_request_limiter_->GetDownloadStatus(web_contents())); |
| } |
| -#if defined(OS_ANDROID) |
| TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { |
| std::unique_ptr<WebContents> web_contents(CreateTestWebContents()); |
| @@ -579,13 +517,8 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { |
| web_contents->GetController().LoadURL( |
| url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string()); |
| - // DownloadRequestLimiter won't try to make a permission bubble if there's |
| - // no permission bubble manager, so don't put one on the test WebContents. |
| - |
| - // DownloadRequestLimiter won't try to make an infobar if it doesn't have an |
| - // InfoBarService, and we want to test that it will Cancel() instead of |
| - // prompting when it doesn't have a InfoBarService, so unset the delegate. |
| - testing_delegate_.UnsetInfobarDelegate(); |
| + // DownloadRequestLimiter won't try to make a permission request if there's |
| + // no permission request manager, so don't put one on the test WebContents. |
| ExpectAndResetCounts(0, 0, 0, __LINE__); |
| EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, |
| download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| @@ -613,7 +546,6 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { |
| EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
| download_request_limiter_->GetDownloadStatus(web_contents.get())); |
| } |
| -#endif |
| TEST_F(DownloadRequestLimiterTest, |
| DownloadRequestLimiter_SetHostContentSetting) { |