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 527de058a27f6a36c96f724bbe2ea666b185617f..019ecff44299e7252294b282417e7eeb329bca5c 100644 |
--- a/chrome/browser/download/download_request_limiter_unittest.cc |
+++ b/chrome/browser/download/download_request_limiter_unittest.cc |
@@ -8,8 +8,6 @@ |
#include "base/command_line.h" |
#include "base/run_loop.h" |
#include "chrome/browser/download/download_permission_request.h" |
-#include "chrome/browser/download/download_request_infobar_delegate.h" |
-#include "chrome/browser/infobars/infobar_service.h" |
#include "chrome/browser/ui/website_settings/permission_bubble_manager.h" |
#include "chrome/common/chrome_switches.h" |
#include "chrome/test/base/chrome_render_view_host_test_harness.h" |
@@ -21,6 +19,11 @@ |
#include "content/public/common/frame_navigate_params.h" |
#include "testing/gtest/include/gtest/gtest.h" |
+#if defined(OS_ANDROID) |
+#include "chrome/browser/download/download_request_infobar_delegate.h" |
+#include "chrome/browser/infobars/infobar_service.h" |
+#endif |
+ |
using content::WebContents; |
class DownloadRequestLimiterTest; |
@@ -82,7 +85,6 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
void SetUp() override { |
ChromeRenderViewHostTestHarness::SetUp(); |
profile_.reset(new TestingProfile()); |
- InfoBarService::CreateForWebContents(web_contents()); |
PermissionBubbleManager::CreateForWebContents(web_contents()); |
scoped_refptr<FakePermissionBubbleView::Factory> factory = |
@@ -95,10 +97,15 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
testing_action_ = ACCEPT; |
ask_allow_count_ = cancel_count_ = continue_count_ = 0; |
download_request_limiter_ = new DownloadRequestLimiter(); |
+ |
+#if defined(OS_ANDROID) |
+ InfoBarService::CreateForWebContents(web_contents()); |
fake_create_callback_ = base::Bind( |
&DownloadRequestLimiterTest::FakeCreate, base::Unretained(this)); |
DownloadRequestInfoBarDelegate::SetCallbackForTesting( |
&fake_create_callback_); |
+#endif |
+ |
content_settings_ = new HostContentSettingsMap(profile_->GetPrefs(), false); |
DownloadRequestLimiter::SetContentSettingsForTesting( |
content_settings_.get()); |
@@ -112,6 +119,16 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
ask_allow_count_++; |
} |
+ void TearDown() override { |
+ content_settings_->ShutdownOnUIThread(); |
+ content_settings_ = NULL; |
+#if defined(OS_ANDROID) |
+ UnsetDelegate(); |
+#endif |
+ ChromeRenderViewHostTestHarness::TearDown(); |
+ } |
+ |
+#if defined(OS_ANDROID) |
void FakeCreate( |
InfoBarService* infobar_service, |
base::WeakPtr<DownloadRequestLimiter::TabDownloadState> host) { |
@@ -128,16 +145,10 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
} |
} |
- void TearDown() override { |
- content_settings_->ShutdownOnUIThread(); |
- content_settings_ = NULL; |
- UnsetDelegate(); |
- ChromeRenderViewHostTestHarness::TearDown(); |
- } |
- |
virtual void UnsetDelegate() { |
DownloadRequestInfoBarDelegate::SetCallbackForTesting(NULL); |
} |
+#endif |
void CanDownload() { |
CanDownloadFor(web_contents()); |
@@ -216,7 +227,10 @@ class DownloadRequestLimiterTest : public ChromeRenderViewHostTestHarness { |
scoped_refptr<HostContentSettingsMap> content_settings_; |
private: |
+#if defined(OS_ANDROID) |
DownloadRequestInfoBarDelegate::FakeCreateCallback fake_create_callback_; |
+#endif |
+ |
scoped_ptr<TestingProfile> profile_; |
}; |
@@ -417,6 +431,7 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_ResetOnReload) { |
download_request_limiter_->GetDownloadStatus(web_contents())); |
} |
+#if defined(OS_ANDROID) |
TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { |
scoped_ptr<WebContents> web_contents(CreateTestWebContents()); |
@@ -454,6 +469,7 @@ TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { |
EXPECT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, |
download_request_limiter_->GetDownloadStatus(web_contents.get())); |
} |
+#endif |
TEST_F(DownloadRequestLimiterTest, |
DownloadRequestLimiter_SetHostContentSetting) { |