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

Side by Side Diff: chrome/browser/download/download_request_limiter_unittest.cc

Issue 1392023004: Rename android only infobars (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: try again Created 5 years, 2 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 unified diff | Download patch
OLDNEW
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/command_line.h" 8 #include "base/command_line.h"
9 #include "base/run_loop.h" 9 #include "base/run_loop.h"
10 #include "chrome/common/chrome_switches.h" 10 #include "chrome/common/chrome_switches.h"
11 #include "chrome/test/base/chrome_render_view_host_test_harness.h" 11 #include "chrome/test/base/chrome_render_view_host_test_harness.h"
12 #include "chrome/test/base/testing_profile.h" 12 #include "chrome/test/base/testing_profile.h"
13 #include "components/content_settings/core/browser/host_content_settings_map.h" 13 #include "components/content_settings/core/browser/host_content_settings_map.h"
14 #include "content/public/browser/navigation_controller.h" 14 #include "content/public/browser/navigation_controller.h"
15 #include "content/public/browser/navigation_details.h" 15 #include "content/public/browser/navigation_details.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/common/frame_navigate_params.h" 17 #include "content/public/common/frame_navigate_params.h"
18 #include "testing/gtest/include/gtest/gtest.h" 18 #include "testing/gtest/include/gtest/gtest.h"
19 19
20 #if defined(OS_ANDROID) 20 #if defined(OS_ANDROID)
21 #include "chrome/browser/download/download_request_infobar_delegate.h" 21 #include "chrome/browser/download/download_request_infobar_delegate_android.h"
22 #include "chrome/browser/infobars/infobar_service.h" 22 #include "chrome/browser/infobars/infobar_service.h"
23 #else 23 #else
24 #include "chrome/browser/download/download_permission_request.h" 24 #include "chrome/browser/download/download_permission_request.h"
25 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h" 25 #include "chrome/browser/ui/website_settings/permission_bubble_manager.h"
26 #endif 26 #endif
27 27
28 using content::WebContents; 28 using content::WebContents;
29 29
30 class DownloadRequestLimiterTest; 30 class DownloadRequestLimiterTest;
31 31
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 #endif 100 #endif
101 101
102 testing_action_ = ACCEPT; 102 testing_action_ = ACCEPT;
103 ask_allow_count_ = cancel_count_ = continue_count_ = 0; 103 ask_allow_count_ = cancel_count_ = continue_count_ = 0;
104 download_request_limiter_ = new DownloadRequestLimiter(); 104 download_request_limiter_ = new DownloadRequestLimiter();
105 105
106 #if defined(OS_ANDROID) 106 #if defined(OS_ANDROID)
107 InfoBarService::CreateForWebContents(web_contents()); 107 InfoBarService::CreateForWebContents(web_contents());
108 fake_create_callback_ = base::Bind( 108 fake_create_callback_ = base::Bind(
109 &DownloadRequestLimiterTest::FakeCreate, base::Unretained(this)); 109 &DownloadRequestLimiterTest::FakeCreate, base::Unretained(this));
110 DownloadRequestInfoBarDelegate::SetCallbackForTesting( 110 DownloadRequestInfoBarDelegateAndroid::SetCallbackForTesting(
111 &fake_create_callback_); 111 &fake_create_callback_);
112 #endif 112 #endif
113 113
114 content_settings_ = new HostContentSettingsMap(profile_->GetPrefs(), false); 114 content_settings_ = new HostContentSettingsMap(profile_->GetPrefs(), false);
115 DownloadRequestLimiter::SetContentSettingsForTesting( 115 DownloadRequestLimiter::SetContentSettingsForTesting(
116 content_settings_.get()); 116 content_settings_.get());
117 } 117 }
118 118
119 int GetAction() { 119 int GetAction() {
120 return testing_action_; 120 return testing_action_;
(...skipping 23 matching lines...) Expand all
144 break; 144 break;
145 case CANCEL: 145 case CANCEL:
146 host->Cancel(); 146 host->Cancel();
147 break; 147 break;
148 case WAIT: 148 case WAIT:
149 break; 149 break;
150 } 150 }
151 } 151 }
152 152
153 virtual void UnsetDelegate() { 153 virtual void UnsetDelegate() {
154 DownloadRequestInfoBarDelegate::SetCallbackForTesting(NULL); 154 DownloadRequestInfoBarDelegateAndroid::SetCallbackForTesting(NULL);
155 } 155 }
156 #endif 156 #endif
157 157
158 void CanDownload() { 158 void CanDownload() {
159 CanDownloadFor(web_contents()); 159 CanDownloadFor(web_contents());
160 } 160 }
161 161
162 void CanDownloadFor(WebContents* web_contents) { 162 void CanDownloadFor(WebContents* web_contents) {
163 download_request_limiter_->CanDownloadImpl( 163 download_request_limiter_->CanDownloadImpl(
164 web_contents, 164 web_contents,
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after
226 // Number of times CancelDownload was invoked. 226 // Number of times CancelDownload was invoked.
227 int cancel_count_; 227 int cancel_count_;
228 228
229 // Number of times ShouldAllowDownload was invoked. 229 // Number of times ShouldAllowDownload was invoked.
230 int ask_allow_count_; 230 int ask_allow_count_;
231 231
232 scoped_refptr<HostContentSettingsMap> content_settings_; 232 scoped_refptr<HostContentSettingsMap> content_settings_;
233 233
234 private: 234 private:
235 #if defined(OS_ANDROID) 235 #if defined(OS_ANDROID)
236 DownloadRequestInfoBarDelegate::FakeCreateCallback fake_create_callback_; 236 DownloadRequestInfoBarDelegateAndroid::FakeCreateCallback
237 fake_create_callback_;
237 #endif 238 #endif
238 239
239 scoped_ptr<TestingProfile> profile_; 240 scoped_ptr<TestingProfile> profile_;
240 }; 241 };
241 242
242 #if !defined(OS_ANDROID) 243 #if !defined(OS_ANDROID)
243 void FakePermissionBubbleView::Show( 244 void FakePermissionBubbleView::Show(
244 const std::vector<PermissionBubbleRequest*>& requests, 245 const std::vector<PermissionBubbleRequest*>& requests,
245 const std::vector<bool>& accept_state) { 246 const std::vector<bool>& accept_state) {
246 test_->AskAllow(); 247 test_->AskAllow();
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 CanDownload(); 500 CanDownload();
500 ExpectAndResetCounts(0, 1, 0, __LINE__); 501 ExpectAndResetCounts(0, 1, 0, __LINE__);
501 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, 502 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD,
502 download_request_limiter_->GetDownloadStatus(web_contents())); 503 download_request_limiter_->GetDownloadStatus(web_contents()));
503 504
504 CanDownload(); 505 CanDownload();
505 ExpectAndResetCounts(0, 1, 0, __LINE__); 506 ExpectAndResetCounts(0, 1, 0, __LINE__);
506 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, 507 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD,
507 download_request_limiter_->GetDownloadStatus(web_contents())); 508 download_request_limiter_->GetDownloadStatus(web_contents()));
508 } 509 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698