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

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

Issue 2349603003: V4LDBM: Get response from GetHashManager, detect severest result (Closed)
Patch Set: git pull Created 4 years, 2 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_get_hash_protocol_manager.h" 5 #include "components/safe_browsing_db/v4_get_hash_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"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/run_loop.h" 12 #include "base/run_loop.h"
13 #include "base/strings/stringprintf.h" 13 #include "base/strings/stringprintf.h"
14 #include "base/test/simple_test_clock.h" 14 #include "base/test/simple_test_clock.h"
15 #include "base/time/time.h" 15 #include "base/time/time.h"
16 #include "components/safe_browsing_db/safebrowsing.pb.h" 16 #include "components/safe_browsing_db/safebrowsing.pb.h"
17 #include "components/safe_browsing_db/testing_util.h" 17 #include "components/safe_browsing_db/testing_util.h"
18 #include "components/safe_browsing_db/util.h" 18 #include "components/safe_browsing_db/util.h"
19 #include "content/public/test/test_browser_thread_bundle.h"
19 #include "net/base/escape.h" 20 #include "net/base/escape.h"
20 #include "net/base/load_flags.h" 21 #include "net/base/load_flags.h"
21 #include "net/base/net_errors.h" 22 #include "net/base/net_errors.h"
22 #include "net/url_request/test_url_fetcher_factory.h" 23 #include "net/url_request/test_url_fetcher_factory.h"
23 #include "testing/platform_test.h" 24 #include "testing/platform_test.h"
24 25
25 using base::Time; 26 using base::Time;
26 using base::TimeDelta; 27 using base::TimeDelta;
27 28
28 namespace { 29 namespace {
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 } 155 }
155 156
156 // Serialize. 157 // Serialize.
157 std::string res_data; 158 std::string res_data;
158 res.SerializeToString(&res_data); 159 res.SerializeToString(&res_data);
159 160
160 return res_data; 161 return res_data;
161 } 162 }
162 163
163 bool callback_called_; 164 bool callback_called_;
165 content::TestBrowserThreadBundle thread_bundle_;
164 }; 166 };
165 167
166 TEST_F(V4GetHashProtocolManagerTest, TestGetHashErrorHandlingNetwork) { 168 TEST_F(V4GetHashProtocolManagerTest, TestGetHashErrorHandlingNetwork) {
167 net::TestURLFetcherFactory factory; 169 net::TestURLFetcherFactory factory;
168 std::unique_ptr<V4GetHashProtocolManager> pm(CreateProtocolManager()); 170 std::unique_ptr<V4GetHashProtocolManager> pm(CreateProtocolManager());
169 171
170 FullHashToStoreAndHashPrefixesMap matched_locally; 172 FullHashToStoreAndHashPrefixesMap matched_locally;
171 matched_locally[FullHash("AHashFull")].emplace_back(GetUrlSocEngId(), 173 matched_locally[FullHash("AHashFull")].emplace_back(GetUrlSocEngId(),
172 HashPrefix("AHash")); 174 HashPrefix("AHash"));
173 std::vector<FullHashInfo> expected_results; 175 std::vector<FullHashInfo> expected_results;
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after
725 full_hash = FullHash("Everything's shiny, Cap'n."); 727 full_hash = FullHash("Everything's shiny, Cap'n.");
726 info = ResponseInfo(full_hash, GetChromeUrlApiId()); 728 info = ResponseInfo(full_hash, GetChromeUrlApiId());
727 info.key_values.emplace_back("permission", "GEOLOCATION"); 729 info.key_values.emplace_back("permission", "GEOLOCATION");
728 infos.push_back(info); 730 infos.push_back(info);
729 SetupFetcherToReturnOKResponse(factory, infos); 731 SetupFetcherToReturnOKResponse(factory, infos);
730 732
731 EXPECT_TRUE(callback_called()); 733 EXPECT_TRUE(callback_called());
732 } 734 }
733 735
734 } // namespace safe_browsing 736 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698