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

Unified Diff: components/safe_browsing_db/v4_database_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, 6 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « components/safe_browsing_db/v4_database.cc ('k') | components/safe_browsing_db/v4_local_database_manager.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: components/safe_browsing_db/v4_database_unittest.cc
diff --git a/components/safe_browsing_db/v4_database_unittest.cc b/components/safe_browsing_db/v4_database_unittest.cc
index 1cd04c6ca1ed445e4b1556e90d19307346e1e59c..2dee2a6628de72c77498d87c39b3009c15f7979e 100644
--- a/components/safe_browsing_db/v4_database_unittest.cc
+++ b/components/safe_browsing_db/v4_database_unittest.cc
@@ -126,17 +126,20 @@ class V4DatabaseTest : public PlatformTest {
v4_database_ = std::move(v4_database);
}
- void PopulateFakeUpdateResponse(StoreStateMap store_state_map,
- std::vector<ListUpdateResponse>* responses) {
+ std::unique_ptr<ParsedServerResponse> CreateFakeServerResponse(
+ StoreStateMap store_state_map) {
+ std::unique_ptr<ParsedServerResponse> parsed_server_response(
+ new ParsedServerResponse);
for (const auto& store_state_iter : store_state_map) {
UpdateListIdentifier identifier = store_state_iter.first;
- ListUpdateResponse list_update_response;
- list_update_response.set_platform_type(identifier.platform_type);
- list_update_response.set_threat_entry_type(identifier.threat_entry_type);
- list_update_response.set_threat_type(identifier.threat_type);
- list_update_response.set_new_client_state(store_state_iter.second);
- responses->push_back(list_update_response);
+ ListUpdateResponse* list_update_response = new ListUpdateResponse;
+ list_update_response->set_platform_type(identifier.platform_type);
+ list_update_response->set_threat_entry_type(identifier.threat_entry_type);
+ list_update_response->set_threat_type(identifier.threat_type);
+ list_update_response->set_new_client_state(store_state_iter.second);
+ parsed_server_response->push_back(base::WrapUnique(list_update_response));
}
+ return parsed_server_response;
}
void VerifyExpectedStoresState(bool expect_new_stores) {
@@ -234,9 +237,8 @@ TEST_F(V4DatabaseTest, TestApplyUpdateWithNewStates) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- PopulateFakeUpdateResponse(expected_store_state_map_, &update_response);
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ v4_database_->ApplyUpdate(CreateFakeServerResponse(expected_store_state_map_),
+ callback_db_updated_);
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();
@@ -265,9 +267,8 @@ TEST_F(V4DatabaseTest, TestApplyUpdateWithNoNewState) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- PopulateFakeUpdateResponse(expected_store_state_map_, &update_response);
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ v4_database_->ApplyUpdate(CreateFakeServerResponse(expected_store_state_map_),
+ callback_db_updated_);
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();
@@ -296,8 +297,10 @@ TEST_F(V4DatabaseTest, TestApplyUpdateWithEmptyUpdate) {
old_stores_map_[store_iter.first] = store;
}
- std::vector<ListUpdateResponse> update_response;
- v4_database_->ApplyUpdate(update_response, callback_db_updated_);
+ std::unique_ptr<ParsedServerResponse> parsed_server_response(
+ new ParsedServerResponse);
+ v4_database_->ApplyUpdate(std::move(parsed_server_response),
+ callback_db_updated_);
task_runner_->RunPendingTasks();
base::RunLoop().RunUntilIdle();
« no previous file with comments | « components/safe_browsing_db/v4_database.cc ('k') | components/safe_browsing_db/v4_local_database_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698