| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/fileapi/upload_file_system_file_element_reader.h" | 5 #include "content/browser/fileapi/upload_file_system_file_element_reader.h" |
| 6 | 6 |
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" |
| 8 #include "base/message_loop/message_loop.h" | 8 #include "base/message_loop/message_loop.h" |
| 9 #include "base/run_loop.h" | 9 #include "base/run_loop.h" |
| 10 #include "content/public/test/async_file_test_helper.h" | 10 #include "content/public/test/async_file_test_helper.h" |
| (...skipping 18 matching lines...) Expand all Loading... |
| 29 const char kFileSystemURLOrigin[] = "http://remote"; | 29 const char kFileSystemURLOrigin[] = "http://remote"; |
| 30 const storage::FileSystemType kFileSystemType = | 30 const storage::FileSystemType kFileSystemType = |
| 31 storage::kFileSystemTypeTemporary; | 31 storage::kFileSystemTypeTemporary; |
| 32 | 32 |
| 33 } // namespace | 33 } // namespace |
| 34 | 34 |
| 35 class UploadFileSystemFileElementReaderTest : public testing::Test { | 35 class UploadFileSystemFileElementReaderTest : public testing::Test { |
| 36 public: | 36 public: |
| 37 UploadFileSystemFileElementReaderTest() {} | 37 UploadFileSystemFileElementReaderTest() {} |
| 38 | 38 |
| 39 virtual void SetUp() OVERRIDE { | 39 virtual void SetUp() override { |
| 40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 40 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 41 | 41 |
| 42 file_system_context_ = CreateFileSystemContextForTesting( | 42 file_system_context_ = CreateFileSystemContextForTesting( |
| 43 NULL, temp_dir_.path()); | 43 NULL, temp_dir_.path()); |
| 44 | 44 |
| 45 file_system_context_->OpenFileSystem( | 45 file_system_context_->OpenFileSystem( |
| 46 GURL(kFileSystemURLOrigin), | 46 GURL(kFileSystemURLOrigin), |
| 47 kFileSystemType, | 47 kFileSystemType, |
| 48 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, | 48 storage::OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT, |
| 49 base::Bind(&UploadFileSystemFileElementReaderTest::OnOpenFileSystem, | 49 base::Bind(&UploadFileSystemFileElementReaderTest::OnOpenFileSystem, |
| (...skipping 17 matching lines...) Expand all Loading... |
| 67 kuint64max, | 67 kuint64max, |
| 68 file_modification_time_)); | 68 file_modification_time_)); |
| 69 net::TestCompletionCallback callback; | 69 net::TestCompletionCallback callback; |
| 70 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(callback.callback())); | 70 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(callback.callback())); |
| 71 EXPECT_EQ(net::OK, callback.WaitForResult()); | 71 EXPECT_EQ(net::OK, callback.WaitForResult()); |
| 72 EXPECT_EQ(file_data_.size(), reader_->GetContentLength()); | 72 EXPECT_EQ(file_data_.size(), reader_->GetContentLength()); |
| 73 EXPECT_EQ(file_data_.size(), reader_->BytesRemaining()); | 73 EXPECT_EQ(file_data_.size(), reader_->BytesRemaining()); |
| 74 EXPECT_FALSE(reader_->IsInMemory()); | 74 EXPECT_FALSE(reader_->IsInMemory()); |
| 75 } | 75 } |
| 76 | 76 |
| 77 virtual void TearDown() OVERRIDE { | 77 virtual void TearDown() override { |
| 78 reader_.reset(); | 78 reader_.reset(); |
| 79 base::RunLoop().RunUntilIdle(); | 79 base::RunLoop().RunUntilIdle(); |
| 80 } | 80 } |
| 81 | 81 |
| 82 protected: | 82 protected: |
| 83 GURL GetFileSystemURL(const std::string& filename) { | 83 GURL GetFileSystemURL(const std::string& filename) { |
| 84 return GURL(file_system_root_url_.spec() + filename); | 84 return GURL(file_system_root_url_.spec() + filename); |
| 85 } | 85 } |
| 86 | 86 |
| 87 void WriteFileSystemFile(const std::string& filename, | 87 void WriteFileSystemFile(const std::string& filename, |
| (...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 274 TEST_F(UploadFileSystemFileElementReaderTest, WrongURL) { | 274 TEST_F(UploadFileSystemFileElementReaderTest, WrongURL) { |
| 275 const GURL wrong_url = GetFileSystemURL("wrong_file_name.dat"); | 275 const GURL wrong_url = GetFileSystemURL("wrong_file_name.dat"); |
| 276 reader_.reset(new UploadFileSystemFileElementReader( | 276 reader_.reset(new UploadFileSystemFileElementReader( |
| 277 file_system_context_.get(), wrong_url, 0, kuint64max, base::Time())); | 277 file_system_context_.get(), wrong_url, 0, kuint64max, base::Time())); |
| 278 net::TestCompletionCallback init_callback; | 278 net::TestCompletionCallback init_callback; |
| 279 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(init_callback.callback())); | 279 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(init_callback.callback())); |
| 280 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); | 280 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); |
| 281 } | 281 } |
| 282 | 282 |
| 283 } // namespace content | 283 } // namespace content |
| OLD | NEW |