| Index: chrome/browser/download/base_file_unittest.cc
|
| ===================================================================
|
| --- chrome/browser/download/base_file_unittest.cc (revision 70630)
|
| +++ chrome/browser/download/base_file_unittest.cc (working copy)
|
| @@ -23,7 +23,8 @@
|
|
|
| virtual void SetUp() {
|
| ASSERT_TRUE(temp_dir_.CreateUniqueTempDir());
|
| - base_file_.reset(new BaseFile(FilePath(), GURL(), GURL(), 0, file_stream_));
|
| + base_file_.reset(
|
| + new BaseFile(FilePath(), GURL(), GURL(), 0, file_stream_, false));
|
| }
|
|
|
| virtual void TearDown() {
|
| @@ -108,6 +109,41 @@
|
| EXPECT_FALSE(base_file_->path_renamed());
|
| }
|
|
|
| +// Write data to the file once and calculate its sha256 hash.
|
| +TEST_F(BaseFileTest, SingleWriteWithHash) {
|
| + base_file_.reset(
|
| + new BaseFile(FilePath(), GURL(), GURL(), 0, file_stream_, true));
|
| + ASSERT_TRUE(base_file_->Initialize());
|
| + AppendDataToFile(kTestData1);
|
| + base_file_->Finish();
|
| +
|
| + EXPECT_FALSE(base_file_->path_renamed());
|
| +
|
| + std::string hash;
|
| + base_file_->GetSha256Hash(&hash);
|
| + EXPECT_EQ("0b2d3f3f7943ad64b860df94d05cb56a8a97c6ec5768b5b70b930c5aa7fa9ade",
|
| + hash);
|
| +}
|
| +
|
| +// Write data to the file multiple times and calculate its sha256 hash.
|
| +TEST_F(BaseFileTest, MultipleWritesWithHash) {
|
| + base_file_.reset(
|
| + new BaseFile(FilePath(), GURL(), GURL(), 0, file_stream_, true));
|
| + ASSERT_TRUE(base_file_->Initialize());
|
| + AppendDataToFile(kTestData1);
|
| + AppendDataToFile(kTestData2);
|
| + AppendDataToFile(kTestData3);
|
| + base_file_->Finish();
|
| +
|
| + EXPECT_FALSE(base_file_->path_renamed());
|
| +
|
| + std::string hash;
|
| + base_file_->GetSha256Hash(&hash);
|
| + EXPECT_EQ("cbf68bf10f8003db86b31343afac8c7175bd03fb5fc905650f8c80af087443a8",
|
| + hash);
|
| +}
|
| +
|
| +
|
| // Rename the file after all writes to it.
|
| TEST_F(BaseFileTest, WriteThenRename) {
|
| ASSERT_TRUE(base_file_->Initialize());
|
|
|
| Property changes on: chrome/browser/download/base_file_unittest.cc
|
| ___________________________________________________________________
|
| Added: svn:eol-style
|
| + LF
|
|
|
|
|