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

Side by Side Diff: chrome/browser/safe_browsing/incident_reporting/last_download_finder_unittest.cc

Issue 833033002: Remove dependency on //content from history DownloadDatabase (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove obsolete #include Created 5 years, 11 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h " 5 #include "chrome/browser/safe_browsing/incident_reporting/last_download_finder.h "
6 6
7 #include <string> 7 #include <string>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/files/file_util.h" 12 #include "base/files/file_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/strings/string_number_conversions.h" 14 #include "base/strings/string_number_conversions.h"
15 #include "base/strings/utf_string_conversions.h" 15 #include "base/strings/utf_string_conversions.h"
16 #include "chrome/browser/history/chrome_history_client.h" 16 #include "chrome/browser/history/chrome_history_client.h"
17 #include "chrome/browser/history/chrome_history_client_factory.h" 17 #include "chrome/browser/history/chrome_history_client_factory.h"
18 #include "chrome/browser/history/download_row.h"
19 #include "chrome/browser/history/history_service.h" 18 #include "chrome/browser/history/history_service.h"
20 #include "chrome/browser/history/history_service_factory.h" 19 #include "chrome/browser/history/history_service_factory.h"
21 #include "chrome/browser/history/web_history_service_factory.h" 20 #include "chrome/browser/history/web_history_service_factory.h"
22 #include "chrome/browser/prefs/browser_prefs.h" 21 #include "chrome/browser/prefs/browser_prefs.h"
23 #include "chrome/browser/profiles/profile_manager.h" 22 #include "chrome/browser/profiles/profile_manager.h"
24 #include "chrome/common/chrome_constants.h" 23 #include "chrome/common/chrome_constants.h"
25 #include "chrome/common/pref_names.h" 24 #include "chrome/common/pref_names.h"
26 #include "chrome/common/safe_browsing/csd.pb.h" 25 #include "chrome/common/safe_browsing/csd.pb.h"
27 #include "chrome/test/base/testing_browser_process.h" 26 #include "chrome/test/base/testing_browser_process.h"
28 #include "chrome/test/base/testing_pref_service_syncable.h" 27 #include "chrome/test/base/testing_pref_service_syncable.h"
29 #include "chrome/test/base/testing_profile.h" 28 #include "chrome/test/base/testing_profile.h"
30 #include "chrome/test/base/testing_profile_manager.h" 29 #include "chrome/test/base/testing_profile_manager.h"
30 #include "components/history/content/browser/download_constants_utils.h"
31 #include "components/history/core/browser/download_constants.h"
32 #include "components/history/core/browser/download_row.h"
31 #include "components/history/core/browser/history_constants.h" 33 #include "components/history/core/browser/history_constants.h"
32 #include "content/public/test/test_browser_thread_bundle.h" 34 #include "content/public/test/test_browser_thread_bundle.h"
33 #include "content/public/test/test_utils.h" 35 #include "content/public/test/test_utils.h"
34 #include "testing/gtest/include/gtest/gtest.h" 36 #include "testing/gtest/include/gtest/gtest.h"
35 37
36 namespace { 38 namespace {
37 39
38 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a 40 // A BrowserContextKeyedServiceFactory::TestingFactoryFunction that creates a
39 // HistoryService for a TestingProfile. 41 // HistoryService for a TestingProfile.
40 KeyedService* BuildHistoryService(content::BrowserContext* context) { 42 KeyedService* BuildHistoryService(content::BrowserContext* context) {
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
211 } 213 }
212 214
213 history::DownloadRow CreateTestDownloadRow() { 215 history::DownloadRow CreateTestDownloadRow() {
214 base::Time now(base::Time::Now()); 216 base::Time now(base::Time::Now());
215 return history::DownloadRow( 217 return history::DownloadRow(
216 base::FilePath(FILE_PATH_LITERAL("spam.exe")), 218 base::FilePath(FILE_PATH_LITERAL("spam.exe")),
217 base::FilePath(FILE_PATH_LITERAL("spam.exe")), 219 base::FilePath(FILE_PATH_LITERAL("spam.exe")),
218 std::vector<GURL>(1, GURL("http://www.google.com")), // url_chain 220 std::vector<GURL>(1, GURL("http://www.google.com")), // url_chain
219 GURL(), // referrer 221 GURL(), // referrer
220 "application/octet-stream", // mime_type 222 "application/octet-stream", // mime_type
221 "application/octet-stream", // original_mime_type 223 "application/octet-stream", // original_mime_type
222 now - base::TimeDelta::FromMinutes(10), // start 224 now - base::TimeDelta::FromMinutes(10), // start
223 now - base::TimeDelta::FromMinutes(9), // end 225 now - base::TimeDelta::FromMinutes(9), // end
224 std::string(), // etag 226 std::string(), // etag
225 std::string(), // last_modified 227 std::string(), // last_modified
226 47LL, // received 228 47LL, // received
227 47LL, // total 229 47LL, // total
228 content::DownloadItem::COMPLETE, // download_state 230 history::DownloadState::COMPLETE, // download_state
229 content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS, // danger_type 231 history::DownloadDangerType::NOT_DANGEROUS, // danger_type
230 content::DOWNLOAD_INTERRUPT_REASON_NONE, // interrupt_reason, 232 history::ToHistoryDownloadInterruptReason(
231 1, // id 233 content::DOWNLOAD_INTERRUPT_REASON_NONE), // interrupt_reason,
232 false, // download_opened 234 1, // id
233 std::string(), // ext_id 235 false, // download_opened
234 std::string()); // ext_name 236 std::string(), // ext_id
237 std::string()); // ext_name
235 } 238 }
236 239
237 void ExpectNoDownloadFound( 240 void ExpectNoDownloadFound(
238 scoped_ptr<ClientIncidentReport_DownloadDetails> download) { 241 scoped_ptr<ClientIncidentReport_DownloadDetails> download) {
239 EXPECT_FALSE(download); 242 EXPECT_FALSE(download);
240 } 243 }
241 244
242 void ExpectFoundTestDownload( 245 void ExpectFoundTestDownload(
243 scoped_ptr<ClientIncidentReport_DownloadDetails> download) { 246 scoped_ptr<ClientIncidentReport_DownloadDetails> download) {
244 ASSERT_TRUE(download); 247 ASSERT_TRUE(download);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
334 base::Unretained(this), 337 base::Unretained(this),
335 &last_download, 338 &last_download,
336 run_loop.QuitClosure()))); 339 run_loop.QuitClosure())));
337 340
338 run_loop.Run(); 341 run_loop.Run();
339 342
340 ExpectFoundTestDownload(last_download.Pass()); 343 ExpectFoundTestDownload(last_download.Pass());
341 } 344 }
342 345
343 } // namespace safe_browsing 346 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698