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

Unified Diff: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc

Issue 2062013002: Fetch incremental updates. Store new state in V4Store. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Nit: Use base::SStringPrintf instead of string concat 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
Index: components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
diff --git a/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc b/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
index 336c7e7db2a64c2d58ce9afdad545c74fab5f50a..92af5fa6404a902e27854f6589e45855431dd91c 100644
--- a/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
+++ b/components/safe_browsing_db/v4_update_protocol_manager_unittest.cc
@@ -58,8 +58,6 @@ class V4UpdateProtocolManagerTest : public testing::Test {
}
std::unique_ptr<V4UpdateProtocolManager> CreateProtocolManager(
- const base::hash_map<UpdateListIdentifier, std::string>
- current_list_states,
const std::vector<ListUpdateResponse>& expected_lurs) {
V4ProtocolConfig config;
config.client_name = kClient;
@@ -67,28 +65,27 @@ class V4UpdateProtocolManagerTest : public testing::Test {
config.key_param = kKeyParam;
config.disable_auto_update = false;
return V4UpdateProtocolManager::Create(
- NULL, config, current_list_states,
+ NULL, config,
base::Bind(&V4UpdateProtocolManagerTest::ValidateGetUpdatesResults,
base::Unretained(this), expected_lurs));
}
- void SetupCurrentListStates(
- base::hash_map<UpdateListIdentifier, std::string>* current_list_states) {
+ void SetupStoreStates(StoreStateMap* store_state_map) {
UpdateListIdentifier list_identifier;
list_identifier.platform_type = WINDOWS_PLATFORM;
list_identifier.threat_entry_type = URL;
list_identifier.threat_type = MALWARE_THREAT;
- current_list_states->insert({list_identifier, "initial_state_1"});
+ store_state_map->insert({list_identifier, "initial_state_1"});
list_identifier.platform_type = WINDOWS_PLATFORM;
list_identifier.threat_entry_type = URL;
list_identifier.threat_type = UNWANTED_SOFTWARE;
- current_list_states->insert({list_identifier, "initial_state_2"});
+ store_state_map->insert({list_identifier, "initial_state_2"});
list_identifier.platform_type = WINDOWS_PLATFORM;
list_identifier.threat_entry_type = EXECUTABLE;
list_identifier.threat_type = MALWARE_THREAT;
- current_list_states->insert({list_identifier, "initial_state_3"});
+ store_state_map->insert({list_identifier, "initial_state_3"});
}
void SetupExpectedListUpdateResponse(
@@ -145,16 +142,17 @@ TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesErrorHandlingNetwork) {
new base::TestSimpleTaskRunner());
base::ThreadTaskRunnerHandle runner_handler(runner);
net::TestURLFetcherFactory factory;
- const base::hash_map<UpdateListIdentifier, std::string> current_list_states;
const std::vector<ListUpdateResponse> expected_lurs;
std::unique_ptr<V4UpdateProtocolManager> pm(
- CreateProtocolManager(current_list_states, expected_lurs));
+ CreateProtocolManager(expected_lurs));
runner->ClearPendingTasks();
// Initial state. No errors.
EXPECT_EQ(0ul, pm->update_error_count_);
EXPECT_EQ(1ul, pm->update_back_off_mult_);
expect_callback_to_be_called_ = false;
+ StoreStateMap store_state_map;
+ pm->set_store_state_map(&store_state_map);
pm->IssueUpdateRequest();
EXPECT_FALSE(pm->IsUpdateScheduled());
@@ -180,15 +178,16 @@ TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesErrorHandlingResponseCode) {
base::ThreadTaskRunnerHandle runner_handler(runner);
net::TestURLFetcherFactory factory;
const std::vector<ListUpdateResponse> expected_lurs;
- const base::hash_map<UpdateListIdentifier, std::string> current_list_states;
std::unique_ptr<V4UpdateProtocolManager> pm(
- CreateProtocolManager(current_list_states, expected_lurs));
+ CreateProtocolManager(expected_lurs));
runner->ClearPendingTasks();
// Initial state. No errors.
EXPECT_EQ(0ul, pm->update_error_count_);
EXPECT_EQ(1ul, pm->update_back_off_mult_);
expect_callback_to_be_called_ = false;
+ StoreStateMap store_state_map;
+ pm->set_store_state_map(&store_state_map);
pm->IssueUpdateRequest();
EXPECT_FALSE(pm->IsUpdateScheduled());
@@ -216,16 +215,17 @@ TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesNoError) {
net::TestURLFetcherFactory factory;
std::vector<ListUpdateResponse> expected_lurs;
SetupExpectedListUpdateResponse(&expected_lurs);
- base::hash_map<UpdateListIdentifier, std::string> current_list_states;
- SetupCurrentListStates(&current_list_states);
std::unique_ptr<V4UpdateProtocolManager> pm(
- CreateProtocolManager(current_list_states, expected_lurs));
+ CreateProtocolManager(expected_lurs));
runner->ClearPendingTasks();
// Initial state. No errors.
EXPECT_EQ(0ul, pm->update_error_count_);
EXPECT_EQ(1ul, pm->update_back_off_mult_);
expect_callback_to_be_called_ = true;
+ StoreStateMap store_state_map;
+ SetupStoreStates(&store_state_map);
+ pm->set_store_state_map(&store_state_map);
pm->IssueUpdateRequest();
EXPECT_FALSE(pm->IsUpdateScheduled());
@@ -252,16 +252,17 @@ TEST_F(V4UpdateProtocolManagerTest, TestGetUpdatesWithOneBackoff) {
net::TestURLFetcherFactory factory;
std::vector<ListUpdateResponse> expected_lurs;
SetupExpectedListUpdateResponse(&expected_lurs);
- base::hash_map<UpdateListIdentifier, std::string> current_list_states;
- SetupCurrentListStates(&current_list_states);
std::unique_ptr<V4UpdateProtocolManager> pm(
- CreateProtocolManager(current_list_states, expected_lurs));
+ CreateProtocolManager(expected_lurs));
runner->ClearPendingTasks();
// Initial state. No errors.
EXPECT_EQ(0ul, pm->update_error_count_);
EXPECT_EQ(1ul, pm->update_back_off_mult_);
expect_callback_to_be_called_ = false;
+ StoreStateMap store_state_map;
+ SetupStoreStates(&store_state_map);
+ pm->set_store_state_map(&store_state_map);
pm->IssueUpdateRequest();
EXPECT_FALSE(pm->IsUpdateScheduled());

Powered by Google App Engine
This is Rietveld 408576698