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

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

Issue 102873002: Move GetFileSize, NormalizeFilePath to base namespace (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years 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
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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 <sstream> 5 #include <sstream>
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 659 matching lines...) Expand 10 before | Expand all | Expand 10 after
670 if (!origin_file_exists) 670 if (!origin_file_exists)
671 return false; 671 return false;
672 672
673 // Confirm the downloaded data file exists. 673 // Confirm the downloaded data file exists.
674 bool downloaded_file_exists = base::PathExists(downloaded_file); 674 bool downloaded_file_exists = base::PathExists(downloaded_file);
675 EXPECT_TRUE(downloaded_file_exists) << downloaded_file.value(); 675 EXPECT_TRUE(downloaded_file_exists) << downloaded_file.value();
676 if (!downloaded_file_exists) 676 if (!downloaded_file_exists)
677 return false; 677 return false;
678 678
679 int64 origin_file_size = 0; 679 int64 origin_file_size = 0;
680 EXPECT_TRUE(file_util::GetFileSize(origin_file, &origin_file_size)); 680 EXPECT_TRUE(base::GetFileSize(origin_file, &origin_file_size));
681 std::string original_file_contents; 681 std::string original_file_contents;
682 EXPECT_TRUE(base::ReadFileToString(origin_file, &original_file_contents)); 682 EXPECT_TRUE(base::ReadFileToString(origin_file, &original_file_contents));
683 EXPECT_TRUE( 683 EXPECT_TRUE(
684 VerifyFile(downloaded_file, original_file_contents, origin_file_size)); 684 VerifyFile(downloaded_file, original_file_contents, origin_file_size));
685 685
686 // Delete the downloaded copy of the file. 686 // Delete the downloaded copy of the file.
687 bool downloaded_file_deleted = 687 bool downloaded_file_deleted =
688 file_util::DieFileDie(downloaded_file, false); 688 file_util::DieFileDie(downloaded_file, false);
689 EXPECT_TRUE(downloaded_file_deleted); 689 EXPECT_TRUE(downloaded_file_deleted);
690 return downloaded_file_deleted; 690 return downloaded_file_deleted;
(...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after
1463 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_IncognitoRegular) { 1463 IN_PROC_BROWSER_TEST_F(DownloadTest, DownloadTest_IncognitoRegular) {
1464 ASSERT_TRUE(test_server()->Start()); 1464 ASSERT_TRUE(test_server()->Start());
1465 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip")); 1465 GURL url(test_server()->GetURL("files/downloads/a_zip_file.zip"));
1466 1466
1467 // Read the origin file now so that we can compare the downloaded files to it 1467 // Read the origin file now so that we can compare the downloaded files to it
1468 // later. 1468 // later.
1469 base::FilePath origin(OriginFile(base::FilePath(FILE_PATH_LITERAL( 1469 base::FilePath origin(OriginFile(base::FilePath(FILE_PATH_LITERAL(
1470 "downloads/a_zip_file.zip")))); 1470 "downloads/a_zip_file.zip"))));
1471 ASSERT_TRUE(base::PathExists(origin)); 1471 ASSERT_TRUE(base::PathExists(origin));
1472 int64 origin_file_size = 0; 1472 int64 origin_file_size = 0;
1473 EXPECT_TRUE(file_util::GetFileSize(origin, &origin_file_size)); 1473 EXPECT_TRUE(base::GetFileSize(origin, &origin_file_size));
1474 std::string original_contents; 1474 std::string original_contents;
1475 EXPECT_TRUE(base::ReadFileToString(origin, &original_contents)); 1475 EXPECT_TRUE(base::ReadFileToString(origin, &original_contents));
1476 1476
1477 std::vector<DownloadItem*> download_items; 1477 std::vector<DownloadItem*> download_items;
1478 GetDownloads(browser(), &download_items); 1478 GetDownloads(browser(), &download_items);
1479 ASSERT_TRUE(download_items.empty()); 1479 ASSERT_TRUE(download_items.empty());
1480 1480
1481 // Download a file in the on-record browser and check that it was downloaded 1481 // Download a file in the on-record browser and check that it was downloaded
1482 // correctly. 1482 // correctly.
1483 DownloadAndWaitWithDisposition(browser(), 1483 DownloadAndWaitWithDisposition(browser(),
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after
3039 // PercentComplete() never regresses. 3039 // PercentComplete() never regresses.
3040 PercentWaiter waiter(download_items[0]); 3040 PercentWaiter waiter(download_items[0]);
3041 EXPECT_TRUE(waiter.WaitForFinished()); 3041 EXPECT_TRUE(waiter.WaitForFinished());
3042 EXPECT_EQ(DownloadItem::COMPLETE, download_items[0]->GetState()); 3042 EXPECT_EQ(DownloadItem::COMPLETE, download_items[0]->GetState());
3043 ASSERT_EQ(100, download_items[0]->PercentComplete()); 3043 ASSERT_EQ(100, download_items[0]->PercentComplete());
3044 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible()); 3044 EXPECT_TRUE(browser()->window()->IsDownloadShelfVisible());
3045 3045
3046 // Check that the file downloaded correctly. 3046 // Check that the file downloaded correctly.
3047 ASSERT_TRUE(base::PathExists(download_items[0]->GetTargetFilePath())); 3047 ASSERT_TRUE(base::PathExists(download_items[0]->GetTargetFilePath()));
3048 int64 downloaded_size = 0; 3048 int64 downloaded_size = 0;
3049 ASSERT_TRUE(file_util::GetFileSize( 3049 ASSERT_TRUE(base::GetFileSize(
3050 download_items[0]->GetTargetFilePath(), &downloaded_size)); 3050 download_items[0]->GetTargetFilePath(), &downloaded_size));
3051 #if defined(OS_WIN) 3051 #if defined(OS_WIN)
3052 ASSERT_EQ(1, downloaded_size); 3052 ASSERT_EQ(1, downloaded_size);
3053 #else 3053 #else
3054 ASSERT_EQ(size + 1, downloaded_size); 3054 ASSERT_EQ(size + 1, downloaded_size);
3055 #endif 3055 #endif
3056 ASSERT_TRUE(file_util::DieFileDie(file_path, false)); 3056 ASSERT_TRUE(file_util::DieFileDie(file_path, false));
3057 ASSERT_TRUE(file_util::DieFileDie(download_items[0]->GetTargetFilePath(), 3057 ASSERT_TRUE(file_util::DieFileDie(download_items[0]->GetTargetFilePath(),
3058 false)); 3058 false));
3059 } 3059 }
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
3250 3250
3251 // No errors this time. The download should complete successfully. 3251 // No errors this time. The download should complete successfully.
3252 EXPECT_FALSE(completion_observer->IsFinished()); 3252 EXPECT_FALSE(completion_observer->IsFinished());
3253 completion_observer->StartObserving(); 3253 completion_observer->StartObserving();
3254 download->Resume(); 3254 download->Resume();
3255 completion_observer->WaitForFinished(); 3255 completion_observer->WaitForFinished();
3256 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState()); 3256 EXPECT_EQ(DownloadItem::COMPLETE, download->GetState());
3257 3257
3258 EXPECT_FALSE(DidShowFileChooser()); 3258 EXPECT_FALSE(DidShowFileChooser());
3259 } 3259 }
OLDNEW
« no previous file with comments | « chrome/browser/diagnostics/recon_diagnostics.cc ('k') | chrome/browser/download/save_page_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698