| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "webkit/fileapi/upload_file_system_file_element_reader.h" | 5 #include "webkit/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.h" | 8 #include "base/message_loop.h" |
| 9 #include "net/base/io_buffer.h" | 9 #include "net/base/io_buffer.h" |
| 10 #include "net/base/test_completion_callback.h" | 10 #include "net/base/test_completion_callback.h" |
| 11 #include "testing/gtest/include/gtest/gtest.h" | 11 #include "testing/gtest/include/gtest/gtest.h" |
| 12 #include "webkit/fileapi/external_mount_points.h" | |
| 13 #include "webkit/fileapi/file_system_context.h" | 12 #include "webkit/fileapi/file_system_context.h" |
| 14 #include "webkit/fileapi/file_system_file_util.h" | 13 #include "webkit/fileapi/file_system_file_util.h" |
| 14 #include "webkit/fileapi/file_system_mount_point_provider.h" |
| 15 #include "webkit/fileapi/file_system_operation_context.h" | 15 #include "webkit/fileapi/file_system_operation_context.h" |
| 16 #include "webkit/fileapi/file_system_task_runners.h" | |
| 17 #include "webkit/fileapi/file_system_url.h" | 16 #include "webkit/fileapi/file_system_url.h" |
| 18 #include "webkit/fileapi/mock_file_system_options.h" | 17 #include "webkit/fileapi/mock_file_system_context.h" |
| 19 | 18 |
| 20 namespace fileapi { | 19 namespace fileapi { |
| 21 | 20 |
| 22 namespace { | 21 namespace { |
| 23 | 22 |
| 24 const char kFileSystemURLOrigin[] = "http://remote"; | 23 const char kFileSystemURLOrigin[] = "http://remote"; |
| 25 const fileapi::FileSystemType kFileSystemType = | 24 const fileapi::FileSystemType kFileSystemType = |
| 26 fileapi::kFileSystemTypeTemporary; | 25 fileapi::kFileSystemTypeTemporary; |
| 27 | 26 |
| 28 } // namespace | 27 } // namespace |
| 29 | 28 |
| 30 class UploadFileSystemFileElementReaderTest : public testing::Test { | 29 class UploadFileSystemFileElementReaderTest : public testing::Test { |
| 31 public: | 30 public: |
| 32 UploadFileSystemFileElementReaderTest() | 31 UploadFileSystemFileElementReaderTest() |
| 33 : message_loop_(MessageLoop::TYPE_IO) {} | 32 : message_loop_(MessageLoop::TYPE_IO) {} |
| 34 | 33 |
| 35 virtual void SetUp() OVERRIDE { | 34 virtual void SetUp() OVERRIDE { |
| 36 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); | 35 ASSERT_TRUE(temp_dir_.CreateUniqueTempDir()); |
| 37 | 36 |
| 38 file_system_context_ = new fileapi::FileSystemContext( | 37 file_system_context_ = fileapi::CreateFileSystemContextForTesting( |
| 39 fileapi::FileSystemTaskRunners::CreateMockTaskRunners(), | 38 NULL, temp_dir_.path()); |
| 40 ExternalMountPoints::CreateRefCounted().get(), | |
| 41 NULL, | |
| 42 NULL, | |
| 43 temp_dir_.path(), | |
| 44 fileapi::CreateDisallowFileAccessOptions()); | |
| 45 | 39 |
| 46 file_system_context_->OpenFileSystem( | 40 file_system_context_->OpenFileSystem( |
| 47 GURL(kFileSystemURLOrigin), | 41 GURL(kFileSystemURLOrigin), |
| 48 kFileSystemType, | 42 kFileSystemType, |
| 49 true, // create | 43 true, // create |
| 50 base::Bind(&UploadFileSystemFileElementReaderTest::OnValidateFileSystem, | 44 base::Bind(&UploadFileSystemFileElementReaderTest::OnValidateFileSystem, |
| 51 base::Unretained(this))); | 45 base::Unretained(this))); |
| 52 MessageLoop::current()->RunUntilIdle(); | 46 MessageLoop::current()->RunUntilIdle(); |
| 53 ASSERT_TRUE(file_system_root_url_.is_valid()); | 47 ASSERT_TRUE(file_system_root_url_.is_valid()); |
| 54 | 48 |
| (...skipping 226 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 281 TEST_F(UploadFileSystemFileElementReaderTest, WrongURL) { | 275 TEST_F(UploadFileSystemFileElementReaderTest, WrongURL) { |
| 282 const GURL wrong_url = GetFileSystemURL("wrong_file_name.dat"); | 276 const GURL wrong_url = GetFileSystemURL("wrong_file_name.dat"); |
| 283 reader_.reset(new UploadFileSystemFileElementReader( | 277 reader_.reset(new UploadFileSystemFileElementReader( |
| 284 file_system_context_, wrong_url, 0, kuint64max, base::Time())); | 278 file_system_context_, wrong_url, 0, kuint64max, base::Time())); |
| 285 net::TestCompletionCallback init_callback; | 279 net::TestCompletionCallback init_callback; |
| 286 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(init_callback.callback())); | 280 ASSERT_EQ(net::ERR_IO_PENDING, reader_->Init(init_callback.callback())); |
| 287 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); | 281 EXPECT_EQ(net::ERR_FILE_NOT_FOUND, init_callback.WaitForResult()); |
| 288 } | 282 } |
| 289 | 283 |
| 290 } // namespace fileapi | 284 } // namespace fileapi |
| OLD | NEW |