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

Unified Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 8438012: Parse the download server response. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove DCHECK bug Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/safe_browsing/download_protection_service_unittest.cc
diff --git a/chrome/browser/safe_browsing/download_protection_service_unittest.cc b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
index be3ca1ee14f763929f19977bb258716a7b8bcc57..2b126274453ec301508fd0e36783949eada1ea51 100644
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc
@@ -224,10 +224,14 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadFetchFailed) {
}
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
+ ClientDownloadResponse response;
+ response.set_verdict(ClientDownloadResponse::SAFE);
FakeURLFetcherFactory factory;
// Empty response means SAFE.
factory.SetFakeResponse(
- DownloadProtectionService::kDownloadRequestUrl, "", true);
+ DownloadProtectionService::kDownloadRequestUrl,
+ response.SerializeAsString(),
+ true);
EXPECT_CALL(*sb_service_, MatchDownloadWhitelistUrl(_))
.WillRepeatedly(Return(false));
@@ -244,8 +248,11 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
EXPECT_EQ(DownloadProtectionService::SAFE, result_);
// Invalid response should be safe too.
+ response.Clear();
factory.SetFakeResponse(
- DownloadProtectionService::kDownloadRequestUrl, "bla", true);
+ DownloadProtectionService::kDownloadRequestUrl,
+ response.SerializePartialAsString(),
+ true);
download_service_->CheckClientDownload(
info,
@@ -253,6 +260,20 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) {
base::Unretained(this)));
msg_loop_.Run();
EXPECT_EQ(DownloadProtectionService::SAFE, result_);
+
+ // If the response is dangerous the result should also be marked as dangerous.
+ response.set_verdict(ClientDownloadResponse::DANGEROUS);
+ factory.SetFakeResponse(
+ DownloadProtectionService::kDownloadRequestUrl,
+ response.SerializeAsString(),
+ true);
+
+ download_service_->CheckClientDownload(
+ info,
+ base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
+ base::Unretained(this)));
+ msg_loop_.Run();
+ EXPECT_EQ(DownloadProtectionService::DANGEROUS, result_);
}
TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) {
« no previous file with comments | « chrome/browser/safe_browsing/download_protection_service.cc ('k') | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698