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

Side by Side Diff: content/browser/download/base_file_unittest.cc

Issue 99923002: Move temp file functions 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 "content/browser/download/base_file.h" 5 #include "content/browser/download/base_file.h"
6 6
7 #include "base/file_util.h" 7 #include "base/file_util.h"
8 #include "base/files/scoped_temp_dir.h" 8 #include "base/files/scoped_temp_dir.h"
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/message_loop/message_loop.h" 10 #include "base/message_loop/message_loop.h"
(...skipping 464 matching lines...) Expand 10 before | Expand all | Expand 10 after
475 EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED, 475 EXPECT_EQ(DOWNLOAD_INTERRUPT_REASON_FILE_ACCESS_DENIED,
476 base_file_->Rename(new_path)); 476 base_file_->Rename(new_path));
477 } 477 }
478 478
479 base_file_->Finish(); 479 base_file_->Finish();
480 } 480 }
481 481
482 // Write data to the file multiple times. 482 // Write data to the file multiple times.
483 TEST_F(BaseFileTest, MultipleWritesWithError) { 483 TEST_F(BaseFileTest, MultipleWritesWithError) {
484 base::FilePath path; 484 base::FilePath path;
485 ASSERT_TRUE(file_util::CreateTemporaryFile(&path)); 485 ASSERT_TRUE(base::CreateTemporaryFile(&path));
486 // Create a new file stream. scoped_ptr takes ownership and passes it to 486 // Create a new file stream. scoped_ptr takes ownership and passes it to
487 // BaseFile; we use the pointer anyway and rely on the BaseFile not 487 // BaseFile; we use the pointer anyway and rely on the BaseFile not
488 // deleting the MockFileStream until the BaseFile is reset. 488 // deleting the MockFileStream until the BaseFile is reset.
489 net::testing::MockFileStream* mock_file_stream( 489 net::testing::MockFileStream* mock_file_stream(
490 new net::testing::MockFileStream(NULL)); 490 new net::testing::MockFileStream(NULL));
491 scoped_ptr<net::FileStream> mock_file_stream_scoped_ptr(mock_file_stream); 491 scoped_ptr<net::FileStream> mock_file_stream_scoped_ptr(mock_file_stream);
492 492
493 ASSERT_EQ(0, 493 ASSERT_EQ(0,
494 mock_file_stream->OpenSync( 494 mock_file_stream->OpenSync(
495 path, 495 path,
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after
616 TEST_F(BaseFileTest, CreatedInDefaultDirectory) { 616 TEST_F(BaseFileTest, CreatedInDefaultDirectory) {
617 ASSERT_TRUE(base_file_->full_path().empty()); 617 ASSERT_TRUE(base_file_->full_path().empty());
618 ASSERT_TRUE(InitializeFile()); 618 ASSERT_TRUE(InitializeFile());
619 EXPECT_FALSE(base_file_->full_path().empty()); 619 EXPECT_FALSE(base_file_->full_path().empty());
620 620
621 // On Windows, CreateTemporaryFileInDir() will cause a path with short names 621 // On Windows, CreateTemporaryFileInDir() will cause a path with short names
622 // to be expanded into a path with long names. Thus temp_dir.path() might not 622 // to be expanded into a path with long names. Thus temp_dir.path() might not
623 // be a string-wise match to base_file_->full_path().DirName() even though 623 // be a string-wise match to base_file_->full_path().DirName() even though
624 // they are in the same directory. 624 // they are in the same directory.
625 base::FilePath temp_file; 625 base::FilePath temp_file;
626 ASSERT_TRUE(file_util::CreateTemporaryFileInDir(temp_dir_.path(), 626 ASSERT_TRUE(base::CreateTemporaryFileInDir(temp_dir_.path(), &temp_file));
627 &temp_file));
628 ASSERT_FALSE(temp_file.empty()); 627 ASSERT_FALSE(temp_file.empty());
629 EXPECT_STREQ(temp_file.DirName().value().c_str(), 628 EXPECT_STREQ(temp_file.DirName().value().c_str(),
630 base_file_->full_path().DirName().value().c_str()); 629 base_file_->full_path().DirName().value().c_str());
631 base_file_->Finish(); 630 base_file_->Finish();
632 } 631 }
633 632
634 } // namespace content 633 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/download/base_file.cc ('k') | content/browser/download/file_metadata_unittest_linux.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698