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

Side by Side Diff: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc

Issue 2103693002: SafeBrowsing PVer4: Send mutable response to the database and the stores (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@02_ReadFromDisk
Patch Set: Minor: Add the explicit keyword for UpdateListIdentifier constructor Created 4 years, 5 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 | « components/safe_browsing_db/v4_update_protocol_manager.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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 "components/safe_browsing_db/v4_update_protocol_manager.h" 5 #include "components/safe_browsing_db/v4_update_protocol_manager.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/base64.h" 10 #include "base/base64.h"
(...skipping 27 matching lines...) Expand all
38 class V4UpdateProtocolManagerTest : public PlatformTest { 38 class V4UpdateProtocolManagerTest : public PlatformTest {
39 void SetUp() override { 39 void SetUp() override {
40 PlatformTest::SetUp(); 40 PlatformTest::SetUp();
41 41
42 SetupStoreStates(); 42 SetupStoreStates();
43 } 43 }
44 44
45 protected: 45 protected:
46 void ValidateGetUpdatesResults( 46 void ValidateGetUpdatesResults(
47 const std::vector<ListUpdateResponse>& expected_lurs, 47 const std::vector<ListUpdateResponse>& expected_lurs,
48 const std::vector<ListUpdateResponse>& list_update_responses) { 48 std::unique_ptr<ParsedServerResponse> parsed_server_response) {
49 // The callback should never be called if expect_callback_to_be_called_ is 49 // The callback should never be called if expect_callback_to_be_called_ is
50 // false. 50 // false.
51 EXPECT_TRUE(expect_callback_to_be_called_); 51 EXPECT_TRUE(expect_callback_to_be_called_);
52 ASSERT_EQ(expected_lurs.size(), list_update_responses.size()); 52 ASSERT_EQ(expected_lurs.size(), parsed_server_response->size());
53 53
54 for (unsigned int i = 0; i < list_update_responses.size(); ++i) { 54 for (unsigned int i = 0; i < parsed_server_response->size(); ++i) {
55 const ListUpdateResponse& expected = expected_lurs[i]; 55 const ListUpdateResponse& expected = expected_lurs[i];
56 const ListUpdateResponse& actual = list_update_responses[i]; 56 const std::unique_ptr<ListUpdateResponse>& actual =
57 57 (*parsed_server_response)[i];
58 EXPECT_EQ(expected.platform_type(), actual.platform_type()); 58 EXPECT_EQ(expected.platform_type(), actual->platform_type());
59 EXPECT_EQ(expected.response_type(), actual.response_type()); 59 EXPECT_EQ(expected.response_type(), actual->response_type());
60 EXPECT_EQ(expected.threat_entry_type(), actual.threat_entry_type()); 60 EXPECT_EQ(expected.threat_entry_type(), actual->threat_entry_type());
61 EXPECT_EQ(expected.threat_type(), actual.threat_type()); 61 EXPECT_EQ(expected.threat_type(), actual->threat_type());
62 EXPECT_EQ(expected.new_client_state(), actual.new_client_state()); 62 EXPECT_EQ(expected.new_client_state(), actual->new_client_state());
63 63
64 // TODO(vakh): Test more fields from the proto. 64 // TODO(vakh): Test more fields from the proto.
65 } 65 }
66 } 66 }
67 67
68 std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager( 68 std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
69 const std::vector<ListUpdateResponse>& expected_lurs) { 69 const std::vector<ListUpdateResponse>& expected_lurs) {
70 V4ProtocolConfig config; 70 V4ProtocolConfig config;
71 config.client_name = kClient; 71 config.client_name = kClient;
72 config.version = kAppVer; 72 config.version = kAppVer;
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after
319 StoreStateMap store_state_map_underscore{ 319 StoreStateMap store_state_map_underscore{
320 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT), 320 {UpdateListIdentifier(LINUX_PLATFORM, URL, MALWARE_THREAT),
321 state_underscore}}; 321 state_underscore}};
322 std::string encoded_request_with_underscore = 322 std::string encoded_request_with_underscore =
323 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto( 323 V4UpdateProtocolManager::GetBase64SerializedUpdateRequestProto(
324 store_state_map_underscore); 324 store_state_map_underscore);
325 EXPECT_EQ("GhEIARACGglVMV8hMF_iUEwoAQ==", encoded_request_with_underscore); 325 EXPECT_EQ("GhEIARACGglVMV8hMF_iUEwoAQ==", encoded_request_with_underscore);
326 } 326 }
327 327
328 } // namespace safe_browsing 328 } // namespace safe_browsing
OLDNEW
« no previous file with comments | « components/safe_browsing_db/v4_update_protocol_manager.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698