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

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

Issue 1767083004: Add DCHECK for primary_url and secondary_url in HostContentSettingsMap::GetPatternsFromScopingType (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: change again... Created 4 years, 9 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
« no previous file with comments | « no previous file | components/content_settings/core/browser/host_content_settings_map.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "build/build_config.h" 10 #include "build/build_config.h"
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 int cancel_count_; 246 int cancel_count_;
247 247
248 scoped_refptr<HostContentSettingsMap> content_settings_; 248 scoped_refptr<HostContentSettingsMap> content_settings_;
249 TestingDelegate testing_delegate_; 249 TestingDelegate testing_delegate_;
250 250
251 private: 251 private:
252 scoped_ptr<TestingProfile> profile_; 252 scoped_ptr<TestingProfile> profile_;
253 }; 253 };
254 254
255 TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_Allow) { 255 TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_Allow) {
256 NavigateAndCommit(GURL("http://foo.com/bar"));
256 LoadCompleted(); 257 LoadCompleted();
257 258
258 // All tabs should initially start at ALLOW_ONE_DOWNLOAD. 259 // All tabs should initially start at ALLOW_ONE_DOWNLOAD.
259 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, 260 ASSERT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD,
260 download_request_limiter_->GetDownloadStatus(web_contents())); 261 download_request_limiter_->GetDownloadStatus(web_contents()));
261 262
262 // Ask if the tab can do a download. This moves to PROMPT_BEFORE_DOWNLOAD. 263 // Ask if the tab can do a download. This moves to PROMPT_BEFORE_DOWNLOAD.
263 CanDownload(); 264 CanDownload();
264 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, 265 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD,
265 download_request_limiter_->GetDownloadStatus(web_contents())); 266 download_request_limiter_->GetDownloadStatus(web_contents()));
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
456 CanDownload(); 457 CanDownload();
457 ExpectAndResetCounts(0, 1, 0, __LINE__); 458 ExpectAndResetCounts(0, 1, 0, __LINE__);
458 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED, 459 ASSERT_EQ(DownloadRequestLimiter::DOWNLOADS_NOT_ALLOWED,
459 download_request_limiter_->GetDownloadStatus(web_contents())); 460 download_request_limiter_->GetDownloadStatus(web_contents()));
460 } 461 }
461 462
462 #if defined(OS_ANDROID) 463 #if defined(OS_ANDROID)
463 TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) { 464 TEST_F(DownloadRequestLimiterTest, DownloadRequestLimiter_RawWebContents) {
464 scoped_ptr<WebContents> web_contents(CreateTestWebContents()); 465 scoped_ptr<WebContents> web_contents(CreateTestWebContents());
465 466
467 // To make sure that url is not empty.
dominickn 2016/03/14 04:02:44 Nit: I don't think this comment is needed.
lshang 2016/03/16 02:42:16 Done.
468 GURL url("http://foo.com/bar");
469 web_contents.get()->GetController().LoadURL(
dominickn 2016/03/14 04:02:44 Nit: I think this can just be web_contents->GetCon
lshang 2016/03/16 02:42:16 Done.
470 url, content::Referrer(), ui::PAGE_TRANSITION_LINK, std::string());
471
466 // DownloadRequestLimiter won't try to make a permission bubble if there's 472 // DownloadRequestLimiter won't try to make a permission bubble if there's
467 // no permission bubble manager, so don't put one on the test WebContents. 473 // no permission bubble manager, so don't put one on the test WebContents.
468 474
469 // DownloadRequestLimiter won't try to make an infobar if it doesn't have an 475 // DownloadRequestLimiter won't try to make an infobar if it doesn't have an
470 // InfoBarService, and we want to test that it will Cancel() instead of 476 // InfoBarService, and we want to test that it will Cancel() instead of
471 // prompting when it doesn't have a InfoBarService, so unset the delegate. 477 // prompting when it doesn't have a InfoBarService, so unset the delegate.
472 testing_delegate_.UnsetInfobarDelegate(); 478 testing_delegate_.UnsetInfobarDelegate();
473 ExpectAndResetCounts(0, 0, 0, __LINE__); 479 ExpectAndResetCounts(0, 0, 0, __LINE__);
474 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD, 480 EXPECT_EQ(DownloadRequestLimiter::ALLOW_ONE_DOWNLOAD,
475 download_request_limiter_->GetDownloadStatus(web_contents.get())); 481 download_request_limiter_->GetDownloadStatus(web_contents.get()));
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 // changing the content setting). 583 // changing the content setting).
578 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK); 584 UpdateContentSettings(web_contents(), CONTENT_SETTING_ASK);
579 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, 585 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD,
580 download_request_limiter_->GetDownloadStatus(web_contents())); 586 download_request_limiter_->GetDownloadStatus(web_contents()));
581 UpdateExpectations(WAIT); 587 UpdateExpectations(WAIT);
582 CanDownload(); 588 CanDownload();
583 ExpectAndResetCounts(0, 0, 1, __LINE__); 589 ExpectAndResetCounts(0, 0, 1, __LINE__);
584 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD, 590 ASSERT_EQ(DownloadRequestLimiter::PROMPT_BEFORE_DOWNLOAD,
585 download_request_limiter_->GetDownloadStatus(web_contents())); 591 download_request_limiter_->GetDownloadStatus(web_contents()));
586 } 592 }
OLDNEW
« no previous file with comments | « no previous file | components/content_settings/core/browser/host_content_settings_map.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698