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

Side by Side Diff: chrome/browser/safe_browsing/download_protection_service_unittest.cc

Issue 2292963004: Make verdict optional in csd proto. (Closed)
Patch Set: Update the unit test to use SAFE as the default value when encountering an invalid value. Created 4 years, 3 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 | chrome/common/safe_browsing/csd.proto » ('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/safe_browsing/download_protection_service.h" 5 #include "chrome/browser/safe_browsing/download_protection_service.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include <map> 10 #include <map>
(...skipping 1061 matching lines...) Expand 10 before | Expand all | Expand 10 after
1072 RunLoop run_loop; 1072 RunLoop run_loop;
1073 download_service_->CheckClientDownload( 1073 download_service_->CheckClientDownload(
1074 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1074 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1075 base::Unretained(this), run_loop.QuitClosure())); 1075 base::Unretained(this), run_loop.QuitClosure()));
1076 run_loop.Run(); 1076 run_loop.Run();
1077 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE)); 1077 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
1078 EXPECT_TRUE(HasClientDownloadRequest()); 1078 EXPECT_TRUE(HasClientDownloadRequest());
1079 ClearClientDownloadRequest(); 1079 ClearClientDownloadRequest();
1080 } 1080 }
1081 { 1081 {
1082 // Invalid response should result in UNKNOWN. 1082 // Invalid response should result in SAFE (default value in proto).
1083 ClientDownloadResponse invalid_response; 1083 ClientDownloadResponse invalid_response;
1084 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(), 1084 factory.SetFakeResponse(DownloadProtectionService::GetDownloadRequestUrl(),
1085 invalid_response.SerializePartialAsString(), 1085 invalid_response.SerializePartialAsString(),
1086 net::HTTP_OK, net::URLRequestStatus::SUCCESS); 1086 net::HTTP_OK, net::URLRequestStatus::SUCCESS);
1087 RunLoop run_loop; 1087 RunLoop run_loop;
1088 download_service_->CheckClientDownload( 1088 download_service_->CheckClientDownload(
1089 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 1089 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
1090 base::Unretained(this), run_loop.QuitClosure())); 1090 base::Unretained(this), run_loop.QuitClosure()));
1091 run_loop.Run(); 1091 run_loop.Run();
1092 EXPECT_TRUE(IsResult(DownloadProtectionService::UNKNOWN)); 1092 EXPECT_TRUE(IsResult(DownloadProtectionService::SAFE));
1093 EXPECT_TRUE(HasClientDownloadRequest()); 1093 EXPECT_TRUE(HasClientDownloadRequest());
1094 ClearClientDownloadRequest(); 1094 ClearClientDownloadRequest();
1095 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting( 1095 EXPECT_FALSE(DownloadFeedbackService::GetPingsForDownloadForTesting(
1096 item, &feedback_ping, &feedback_response)); 1096 item, &feedback_ping, &feedback_response));
1097 } 1097 }
1098 { 1098 {
1099 // If the response is dangerous the result should also be marked as 1099 // If the response is dangerous the result should also be marked as
1100 // dangerous. 1100 // dangerous.
1101 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK, 1101 PrepareResponse(&factory, ClientDownloadResponse::DANGEROUS, net::HTTP_OK,
1102 net::URLRequestStatus::SUCCESS); 1102 net::URLRequestStatus::SUCCESS);
(...skipping 1261 matching lines...) Expand 10 before | Expand all | Expand 10 after
2364 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback, 2364 &item, base::Bind(&DownloadProtectionServiceTest::CheckDoneCallback,
2365 base::Unretained(this), run_loop.QuitClosure())); 2365 base::Unretained(this), run_loop.QuitClosure()));
2366 run_loop.Run(); 2366 run_loop.Run();
2367 2367
2368 EXPECT_FALSE(HasClientDownloadRequest()); 2368 EXPECT_FALSE(HasClientDownloadRequest());
2369 // Overriden by flag: 2369 // Overriden by flag:
2370 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS)); 2370 EXPECT_TRUE(IsResult(DownloadProtectionService::DANGEROUS));
2371 } 2371 }
2372 2372
2373 } // namespace safe_browsing 2373 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « no previous file | chrome/common/safe_browsing/csd.proto » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698