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

Side by Side Diff: chrome/browser/download/download_manager_unittest.cc

Issue 6935032: Include full redirect chain in downloads safebrowsing ping. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: initialize url_chain in tests Created 9 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/download/download_safe_browsing_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 <string> 5 #include <string>
6 #include <set> 6 #include <set>
7 7
8 #include "base/file_util.h" 8 #include "base/file_util.h"
9 #include "base/memory/scoped_ptr.h" 9 #include "base/memory/scoped_ptr.h"
10 #include "base/stl_util-inl.h" 10 #include "base/stl_util-inl.h"
(...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 using ::testing::_; 341 using ::testing::_;
342 using ::testing::CreateFunctor; 342 using ::testing::CreateFunctor;
343 using ::testing::Invoke; 343 using ::testing::Invoke;
344 using ::testing::Return; 344 using ::testing::Return;
345 345
346 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDownloadRenameCases); ++i) { 346 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kDownloadRenameCases); ++i) {
347 // |info| will be destroyed in download_manager_. 347 // |info| will be destroyed in download_manager_.
348 DownloadCreateInfo* info(new DownloadCreateInfo); 348 DownloadCreateInfo* info(new DownloadCreateInfo);
349 info->download_id = static_cast<int>(i); 349 info->download_id = static_cast<int>(i);
350 info->prompt_user_for_save_location = false; 350 info->prompt_user_for_save_location = false;
351 info->url_chain.push_back(GURL());
351 info->is_dangerous_file = kDownloadRenameCases[i].is_dangerous_file; 352 info->is_dangerous_file = kDownloadRenameCases[i].is_dangerous_file;
352 info->is_dangerous_url = kDownloadRenameCases[i].is_dangerous_url; 353 info->is_dangerous_url = kDownloadRenameCases[i].is_dangerous_url;
353 FilePath new_path(kDownloadRenameCases[i].suggested_path); 354 FilePath new_path(kDownloadRenameCases[i].suggested_path);
354 355
355 MockDownloadFile* download_file( 356 MockDownloadFile* download_file(
356 new MockDownloadFile(info, download_manager_)); 357 new MockDownloadFile(info, download_manager_));
357 AddDownloadToFileManager(info->download_id, download_file); 358 AddDownloadToFileManager(info->download_id, download_file);
358 359
359 // |download_file| is owned by DownloadFileManager. 360 // |download_file| is owned by DownloadFileManager.
360 ::testing::Mock::AllowLeak(download_file); 361 ::testing::Mock::AllowLeak(download_file);
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
395 TEST_F(DownloadManagerTest, DownloadInterruptTest) { 396 TEST_F(DownloadManagerTest, DownloadInterruptTest) {
396 using ::testing::_; 397 using ::testing::_;
397 using ::testing::CreateFunctor; 398 using ::testing::CreateFunctor;
398 using ::testing::Invoke; 399 using ::testing::Invoke;
399 using ::testing::Return; 400 using ::testing::Return;
400 401
401 // |info| will be destroyed in download_manager_. 402 // |info| will be destroyed in download_manager_.
402 DownloadCreateInfo* info(new DownloadCreateInfo); 403 DownloadCreateInfo* info(new DownloadCreateInfo);
403 info->download_id = static_cast<int>(0); 404 info->download_id = static_cast<int>(0);
404 info->prompt_user_for_save_location = false; 405 info->prompt_user_for_save_location = false;
406 info->url_chain.push_back(GURL());
405 info->is_dangerous_file = false; 407 info->is_dangerous_file = false;
406 info->is_dangerous_url = false; 408 info->is_dangerous_url = false;
407 const FilePath new_path(FILE_PATH_LITERAL("foo.zip")); 409 const FilePath new_path(FILE_PATH_LITERAL("foo.zip"));
408 const FilePath cr_path(download_util::GetCrDownloadPath(new_path)); 410 const FilePath cr_path(download_util::GetCrDownloadPath(new_path));
409 411
410 MockDownloadFile* download_file( 412 MockDownloadFile* download_file(
411 new MockDownloadFile(info, download_manager_)); 413 new MockDownloadFile(info, download_manager_));
412 AddDownloadToFileManager(info->download_id, download_file); 414 AddDownloadToFileManager(info->download_id, download_file);
413 415
414 // |download_file| is owned by DownloadFileManager. 416 // |download_file| is owned by DownloadFileManager.
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
460 TEST_F(DownloadManagerTest, DownloadCancelTest) { 462 TEST_F(DownloadManagerTest, DownloadCancelTest) {
461 using ::testing::_; 463 using ::testing::_;
462 using ::testing::CreateFunctor; 464 using ::testing::CreateFunctor;
463 using ::testing::Invoke; 465 using ::testing::Invoke;
464 using ::testing::Return; 466 using ::testing::Return;
465 467
466 // |info| will be destroyed in download_manager_. 468 // |info| will be destroyed in download_manager_.
467 DownloadCreateInfo* info(new DownloadCreateInfo); 469 DownloadCreateInfo* info(new DownloadCreateInfo);
468 info->download_id = static_cast<int>(0); 470 info->download_id = static_cast<int>(0);
469 info->prompt_user_for_save_location = false; 471 info->prompt_user_for_save_location = false;
472 info->url_chain.push_back(GURL());
470 info->is_dangerous_file = false; 473 info->is_dangerous_file = false;
471 info->is_dangerous_url = false; 474 info->is_dangerous_url = false;
472 const FilePath new_path(FILE_PATH_LITERAL("foo.zip")); 475 const FilePath new_path(FILE_PATH_LITERAL("foo.zip"));
473 const FilePath cr_path(download_util::GetCrDownloadPath(new_path)); 476 const FilePath cr_path(download_util::GetCrDownloadPath(new_path));
474 477
475 MockDownloadFile* download_file( 478 MockDownloadFile* download_file(
476 new MockDownloadFile(info, download_manager_)); 479 new MockDownloadFile(info, download_manager_));
477 AddDownloadToFileManager(info->download_id, download_file); 480 AddDownloadToFileManager(info->download_id, download_file);
478 481
479 // |download_file| is owned by DownloadFileManager. 482 // |download_file| is owned by DownloadFileManager.
(...skipping 58 matching lines...) Expand 10 before | Expand all | Expand 10 after
538 // which we will override. 541 // which we will override.
539 int uniquifier = download_util::GetUniquePathNumber(new_path); 542 int uniquifier = download_util::GetUniquePathNumber(new_path);
540 FilePath unique_new_path = new_path; 543 FilePath unique_new_path = new_path;
541 EXPECT_NE(0, uniquifier); 544 EXPECT_NE(0, uniquifier);
542 download_util::AppendNumberToPath(&unique_new_path, uniquifier); 545 download_util::AppendNumberToPath(&unique_new_path, uniquifier);
543 546
544 // |info| will be destroyed in download_manager_. 547 // |info| will be destroyed in download_manager_.
545 DownloadCreateInfo* info(new DownloadCreateInfo); 548 DownloadCreateInfo* info(new DownloadCreateInfo);
546 info->download_id = static_cast<int>(0); 549 info->download_id = static_cast<int>(0);
547 info->prompt_user_for_save_location = true; 550 info->prompt_user_for_save_location = true;
551 info->url_chain.push_back(GURL());
548 info->is_dangerous_file = false; 552 info->is_dangerous_file = false;
549 info->is_dangerous_url = false; 553 info->is_dangerous_url = false;
550 554
551 download_manager_->CreateDownloadItem(info); 555 download_manager_->CreateDownloadItem(info);
552 556
553 DownloadItem* download = GetActiveDownloadItem(0); 557 DownloadItem* download = GetActiveDownloadItem(0);
554 ASSERT_TRUE(download != NULL); 558 ASSERT_TRUE(download != NULL);
555 559
556 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state()); 560 EXPECT_EQ(DownloadItem::IN_PROGRESS, download->state());
557 scoped_ptr<ItemObserver> observer(new ItemObserver(download)); 561 scoped_ptr<ItemObserver> observer(new ItemObserver(download));
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 EXPECT_FALSE(observer->was_opened()); 594 EXPECT_FALSE(observer->was_opened());
591 EXPECT_EQ(DownloadItem::COMPLETE, download->state()); 595 EXPECT_EQ(DownloadItem::COMPLETE, download->state());
592 596
593 EXPECT_TRUE(file_util::PathExists(new_path)); 597 EXPECT_TRUE(file_util::PathExists(new_path));
594 EXPECT_FALSE(file_util::PathExists(cr_path)); 598 EXPECT_FALSE(file_util::PathExists(cr_path));
595 EXPECT_FALSE(file_util::PathExists(unique_new_path)); 599 EXPECT_FALSE(file_util::PathExists(unique_new_path));
596 std::string file_contents; 600 std::string file_contents;
597 EXPECT_TRUE(file_util::ReadFileToString(new_path, &file_contents)); 601 EXPECT_TRUE(file_util::ReadFileToString(new_path, &file_contents));
598 EXPECT_EQ(std::string(kTestData), file_contents); 602 EXPECT_EQ(std::string(kTestData), file_contents);
599 } 603 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/download/download_safe_browsing_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698