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

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

Issue 1781983002: [Downloads] Introduce GUIDs for downloads. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Address comments Created 4 years, 9 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 <stddef.h> 7 #include <stddef.h>
8 #include <string> 8 #include <string>
9 #include <utility> 9 #include <utility>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/bind.h" 12 #include "base/bind.h"
13 #include "base/callback.h" 13 #include "base/callback.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/guid.h"
16 #include "base/location.h" 17 #include "base/location.h"
17 #include "base/memory/scoped_ptr.h" 18 #include "base/memory/scoped_ptr.h"
18 #include "base/metrics/field_trial.h" 19 #include "base/metrics/field_trial.h"
19 #include "base/run_loop.h" 20 #include "base/run_loop.h"
20 #include "base/single_thread_task_runner.h" 21 #include "base/single_thread_task_runner.h"
21 #include "base/strings/string_number_conversions.h" 22 #include "base/strings/string_number_conversions.h"
22 #include "base/strings/utf_string_conversions.h" 23 #include "base/strings/utf_string_conversions.h"
23 #include "base/test/mock_entropy_provider.h" 24 #include "base/test/mock_entropy_provider.h"
24 #include "base/thread_task_runner_handle.h" 25 #include "base/thread_task_runner_handle.h"
25 #include "build/build_config.h" 26 #include "build/build_config.h"
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 last_non_binary_download, run_loop.QuitClosure()))); 259 last_non_binary_download, run_loop.QuitClosure())));
259 260
260 if (finder) 261 if (finder)
261 run_loop.Run(); 262 run_loop.Run();
262 } 263 }
263 264
264 history::DownloadRow CreateTestDownloadRow( 265 history::DownloadRow CreateTestDownloadRow(
265 const base::FilePath::CharType* file_path) { 266 const base::FilePath::CharType* file_path) {
266 base::Time now(base::Time::Now()); 267 base::Time now(base::Time::Now());
267 return history::DownloadRow( 268 return history::DownloadRow(
268 base::FilePath(file_path), base::FilePath(file_path), 269 base::FilePath(file_path),
270 base::FilePath(file_path),
269 std::vector<GURL>(1, GURL("http://www.google.com")), // url_chain 271 std::vector<GURL>(1, GURL("http://www.google.com")), // url_chain
270 GURL(), // referrer 272 GURL(), // referrer
273 std::string(), // HTTP method
271 "application/octet-stream", // mime_type 274 "application/octet-stream", // mime_type
272 "application/octet-stream", // original_mime_type 275 "application/octet-stream", // original_mime_type
273 now - base::TimeDelta::FromMinutes(10), // start 276 now - base::TimeDelta::FromMinutes(10), // start
274 now - base::TimeDelta::FromMinutes(9), // end 277 now - base::TimeDelta::FromMinutes(9), // end
275 std::string(), // etag 278 std::string(), // etag
276 std::string(), // last_modified 279 std::string(), // last_modified
277 47LL, // received 280 47LL, // received
278 47LL, // total 281 47LL, // total
279 history::DownloadState::COMPLETE, // download_state 282 history::DownloadState::COMPLETE, // download_state
280 history::DownloadDangerType::NOT_DANGEROUS, // danger_type 283 history::DownloadDangerType::NOT_DANGEROUS, // danger_type
281 history::ToHistoryDownloadInterruptReason( 284 history::ToHistoryDownloadInterruptReason(
282 content::DOWNLOAD_INTERRUPT_REASON_NONE), // interrupt_reason, 285 content::DOWNLOAD_INTERRUPT_REASON_NONE), // interrupt_reason,
286 std::string(), // hash
283 download_id_++, // id 287 download_id_++, // id
284 false, // download_opened 288 base::GenerateGUID(),
285 std::string(), // ext_id 289 false, // download_opened
286 std::string()); // ext_name 290 std::string(), // ext_id
291 std::string()); // ext_name
287 } 292 }
288 293
289 content::TestBrowserThreadBundle browser_thread_bundle_; 294 content::TestBrowserThreadBundle browser_thread_bundle_;
290 scoped_ptr<TestingProfileManager> profile_manager_; 295 scoped_ptr<TestingProfileManager> profile_manager_;
291 296
292 private: 297 private:
293 // A HistoryService::DownloadCreateCallback that asserts that the download was 298 // A HistoryService::DownloadCreateCallback that asserts that the download was
294 // created and runs |closure|. 299 // created and runs |closure|.
295 void ContinueOnDownloadCreated(const base::Closure& closure, bool created) { 300 void ContinueOnDownloadCreated(const base::Closure& closure, bool created) {
296 ASSERT_TRUE(created); 301 ASSERT_TRUE(created);
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after
451 base::Bind(&LastDownloadFinderTest::OnLastDownload, 456 base::Bind(&LastDownloadFinderTest::OnLastDownload,
452 base::Unretained(this), &last_binary_download, 457 base::Unretained(this), &last_binary_download,
453 &last_non_binary_download, run_loop.QuitClosure()))); 458 &last_non_binary_download, run_loop.QuitClosure())));
454 459
455 run_loop.Run(); 460 run_loop.Run();
456 461
457 ASSERT_TRUE(last_binary_download); 462 ASSERT_TRUE(last_binary_download);
458 } 463 }
459 464
460 } // namespace safe_browsing 465 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698