Chromium Code Reviews| 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 f50544112521ea0f896e27a60295621a51b735cf..f4a56a9c9f2241534b5542242889dbdb82906319 100644 |
| --- a/chrome/browser/safe_browsing/download_protection_service_unittest.cc |
| +++ b/chrome/browser/safe_browsing/download_protection_service_unittest.cc |
| @@ -223,10 +223,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)); |
| @@ -243,8 +247,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, |
| @@ -252,6 +259,20 @@ TEST_F(DownloadProtectionServiceTest, CheckClientDownloadSuccess) { |
| base::Unretained(this))); |
| msg_loop_.Run(); |
| EXPECT_EQ(DownloadProtectionService::SAFE, result_); |
| + |
| + // If the response is malicious the result should also be makred as malicious. |
|
mattm
2011/11/01 23:57:53
marked
noelutz
2011/11/02 00:55:31
Done.
|
| + response.set_verdict(ClientDownloadResponse::MALICIOUS); |
| + factory.SetFakeResponse( |
| + DownloadProtectionService::kDownloadRequestUrl, |
| + response.SerializeAsString(), |
| + true); |
| + |
| + download_service_->CheckClientDownload( |
| + info, |
| + base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, |
| + base::Unretained(this))); |
| + msg_loop_.Run(); |
| + EXPECT_EQ(DownloadProtectionService::MALICIOUS, result_); |
| } |
| TEST_F(DownloadProtectionServiceTest, CheckClientDownloadValidateRequest) { |