| 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 <stddef.h> | 5 #include <stddef.h> |
| 6 | 6 |
| 7 #include <map> | 7 #include <map> |
| 8 #include <memory> | 8 #include <memory> |
| 9 #include <queue> | 9 #include <queue> |
| 10 #include <set> | 10 #include <set> |
| (...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 105 void SetUp() override { | 105 void SetUp() override { |
| 106 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 106 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); |
| 107 ASSERT_TRUE(partition_dir_.CreateUniqueTempDir()); | 107 ASSERT_TRUE(partition_dir_.CreateUniqueTempDir()); |
| 108 file_util_.reset(new storage::DraggedFileUtil()); | 108 file_util_.reset(new storage::DraggedFileUtil()); |
| 109 | 109 |
| 110 // Register the files/directories of RegularTestCases (with random | 110 // Register the files/directories of RegularTestCases (with random |
| 111 // root paths) as dropped files. | 111 // root paths) as dropped files. |
| 112 SimulateDropFiles(); | 112 SimulateDropFiles(); |
| 113 | 113 |
| 114 file_system_context_ = CreateFileSystemContextForTesting( | 114 file_system_context_ = CreateFileSystemContextForTesting( |
| 115 NULL /* quota_manager */, | 115 NULL /* quota_manager */, partition_dir_.GetPath()); |
| 116 partition_dir_.path()); | |
| 117 | 116 |
| 118 isolated_context()->AddReference(filesystem_id_); | 117 isolated_context()->AddReference(filesystem_id_); |
| 119 } | 118 } |
| 120 | 119 |
| 121 void TearDown() override { | 120 void TearDown() override { |
| 122 isolated_context()->RemoveReference(filesystem_id_); | 121 isolated_context()->RemoveReference(filesystem_id_); |
| 123 } | 122 } |
| 124 | 123 |
| 125 protected: | 124 protected: |
| 126 storage::IsolatedContext* isolated_context() const { | 125 storage::IsolatedContext* isolated_context() const { |
| 127 return storage::IsolatedContext::GetInstance(); | 126 return storage::IsolatedContext::GetInstance(); |
| 128 } | 127 } |
| 129 const base::FilePath& root_path() const { | 128 const base::FilePath& root_path() const { return data_dir_.GetPath(); } |
| 130 return data_dir_.path(); | |
| 131 } | |
| 132 FileSystemContext* file_system_context() const { | 129 FileSystemContext* file_system_context() const { |
| 133 return file_system_context_.get(); | 130 return file_system_context_.get(); |
| 134 } | 131 } |
| 135 storage::FileSystemFileUtil* file_util() const { return file_util_.get(); } | 132 storage::FileSystemFileUtil* file_util() const { return file_util_.get(); } |
| 136 std::string filesystem_id() const { return filesystem_id_; } | 133 std::string filesystem_id() const { return filesystem_id_; } |
| 137 | 134 |
| 138 base::FilePath GetTestCasePlatformPath( | 135 base::FilePath GetTestCasePlatformPath( |
| 139 const base::FilePath::StringType& path) { | 136 const base::FilePath::StringType& path) { |
| 140 return toplevel_root_map_[GetTopLevelPath(base::FilePath(path))] | 137 return toplevel_root_map_[GetTopLevelPath(base::FilePath(path))] |
| 141 .Append(path).NormalizePathSeparators(); | 138 .Append(path).NormalizePathSeparators(); |
| 142 } | 139 } |
| 143 | 140 |
| 144 base::FilePath GetTestCaseLocalPath(const base::FilePath& path) { | 141 base::FilePath GetTestCaseLocalPath(const base::FilePath& path) { |
| 145 base::FilePath relative; | 142 base::FilePath relative; |
| 146 if (data_dir_.path().AppendRelativePath(path, &relative)) | 143 if (data_dir_.GetPath().AppendRelativePath(path, &relative)) |
| 147 return relative; | 144 return relative; |
| 148 return path; | 145 return path; |
| 149 } | 146 } |
| 150 | 147 |
| 151 FileSystemURL GetFileSystemURL(const base::FilePath& path) const { | 148 FileSystemURL GetFileSystemURL(const base::FilePath& path) const { |
| 152 base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath( | 149 base::FilePath virtual_path = isolated_context()->CreateVirtualRootPath( |
| 153 filesystem_id()).Append(path); | 150 filesystem_id()).Append(path); |
| 154 return file_system_context_->CreateCrackedFileSystemURL( | 151 return file_system_context_->CreateCrackedFileSystemURL( |
| 155 GURL("http://example.com"), | 152 GURL("http://example.com"), |
| 156 storage::kFileSystemTypeIsolated, | 153 storage::kFileSystemTypeIsolated, |
| (...skipping 391 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 548 EXPECT_EQ(base::File::FILE_OK, | 545 EXPECT_EQ(base::File::FILE_OK, |
| 549 file_util()->Truncate(GetOperationContext().get(), url, 999)); | 546 file_util()->Truncate(GetOperationContext().get(), url, 999)); |
| 550 ASSERT_EQ(base::File::FILE_OK, | 547 ASSERT_EQ(base::File::FILE_OK, |
| 551 file_util()->GetFileInfo(GetOperationContext().get(), url, | 548 file_util()->GetFileInfo(GetOperationContext().get(), url, |
| 552 &info, &platform_path)); | 549 &info, &platform_path)); |
| 553 EXPECT_EQ(999, info.size); | 550 EXPECT_EQ(999, info.size); |
| 554 } | 551 } |
| 555 } | 552 } |
| 556 | 553 |
| 557 } // namespace content | 554 } // namespace content |
| OLD | NEW |