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

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: 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
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 std::unique_ptr<ListUpdateResponse>& actual =
Scott Hess - ex-Googler 2016/06/28 03:58:43 const should still be appropriate for a reference.
vakh (use Gerrit instead) 2016/06/28 21:34:14 Done.
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 219 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 fetcher->SetResponseString(GetExpectedV4UpdateResponse(expected_lurs)); 292 fetcher->SetResponseString(GetExpectedV4UpdateResponse(expected_lurs));
293 fetcher->delegate()->OnURLFetchComplete(fetcher); 293 fetcher->delegate()->OnURLFetchComplete(fetcher);
294 294
295 // No error, back off multiplier is unchanged. 295 // No error, back off multiplier is unchanged.
296 EXPECT_EQ(0ul, pm->update_error_count_); 296 EXPECT_EQ(0ul, pm->update_error_count_);
297 EXPECT_EQ(1ul, pm->update_back_off_mult_); 297 EXPECT_EQ(1ul, pm->update_back_off_mult_);
298 EXPECT_FALSE(pm->IsUpdateScheduled()); 298 EXPECT_FALSE(pm->IsUpdateScheduled());
299 } 299 }
300 300
301 } // namespace safe_browsing 301 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698