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 04a46573a2ad35d65bcd0a3de01236e51615f577..d45b7949ea934db435260f581212275e0f1779b1 100644 |
--- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc |
+++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc |
@@ -395,9 +395,12 @@ class DownloadProtectionServiceTest : public testing::Test { |
void PrepareResponse(net::FakeURLFetcherFactory* factory, |
ClientDownloadResponse::Verdict verdict, |
net::HttpStatusCode response_code, |
- net::URLRequestStatus::Status status) { |
+ net::URLRequestStatus::Status status, |
+ bool upload_requested = false) { |
ClientDownloadResponse response; |
response.set_verdict(verdict); |
+ if (upload_requested) |
+ response.set_upload(true); |
factory->SetFakeResponse( |
DownloadProtectionService::GetDownloadRequestUrl(), |
response.SerializeAsString(), |
@@ -1041,11 +1044,11 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { |
MatchDownloadWhitelistUrl(_)) |
.WillRepeatedly(Return(false)); |
EXPECT_CALL(*binary_feature_extractor_.get(), CheckSignature(tmp_path_, _)) |
- .Times(7); |
+ .Times(8); |
EXPECT_CALL(*binary_feature_extractor_.get(), |
ExtractImageFeatures( |
tmp_path_, BinaryFeatureExtractor::kDefaultOptions, _, _)) |
- .Times(7); |
+ .Times(8); |
std::string feedback_ping; |
std::string feedback_response; |
ClientDownloadResponse expected_response; |
@@ -1094,6 +1097,23 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { |
ClearClientDownloadRequest(); |
} |
{ |
+ // If the response is dangerous and the server requests an upload, |
+ // we should upload. |
+ PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, |
+ net::URLRequestStatus::SUCCESS, |
+ true /* upload_requested */); |
+ RunLoop run_loop; |
+ download_service_->CheckClientDownload( |
+ &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
+ base::Unretained(this), run_loop.QuitClosure())); |
+ run_loop.Run(); |
+ EXPECT_TRUE(DownloadFeedbackService::GetPingsForDownloadForTesting( |
+ item, &feedback_ping, &feedback_response)); |
+ EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); |
+ EXPECT_TRUE(HasClientDownloadRequest()); |
+ ClearClientDownloadRequest(); |
+ } |
+ { |
// If the response is uncommon the result should also be marked as uncommon. |
PrepareResponse(&factory, ClientDownloadResponse::UNCOMMON, net::HTTP_OK, |
net::URLRequestStatus::SUCCESS); |