summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 04:24:36 +0000
committerkinuko@chromium.org <kinuko@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-01-23 04:24:36 +0000
commit4f056a870937b82f28bbde8ff4172940a3ea87a4 (patch)
treebb92dabc90be973de5353352949d6ac8de94b730
parentdbeac5a7395be2df51590b4d8f538759bef857f7 (diff)
downloadchromium_src-4f056a870937b82f28bbde8ff4172940a3ea87a4.zip
chromium_src-4f056a870937b82f28bbde8ff4172940a3ea87a4.tar.gz
chromium_src-4f056a870937b82f28bbde8ff4172940a3ea87a4.tar.bz2
Cleanup: Remove FileUtil overriding hack for testing in LocalFileSystemOperation
We needed the hack back then but it looks we no longer need it. (Now we can always get an appropriate FileUtil for a given filesystem type by calling MountPointProvider::GetFileUtil) BUG=none TEST=existing tests (content_unittests:*File*) Review URL: https://codereview.chromium.org/11953023 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@178244 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--webkit/fileapi/file_system_file_util_unittest.cc10
-rw-r--r--webkit/fileapi/file_writer_delegate_unittest.cc2
-rw-r--r--webkit/fileapi/isolated_file_util_unittest.cc15
-rw-r--r--webkit/fileapi/local_file_system_operation.h8
-rw-r--r--webkit/fileapi/local_file_system_operation_unittest.cc3
-rw-r--r--webkit/fileapi/local_file_system_operation_write_unittest.cc3
-rw-r--r--webkit/fileapi/local_file_system_quota_unittest.cc3
-rw-r--r--webkit/fileapi/local_file_system_test_helper.cc48
-rw-r--r--webkit/fileapi/local_file_system_test_helper.h10
-rw-r--r--webkit/fileapi/local_file_util_unittest.cc7
-rw-r--r--webkit/fileapi/obfuscated_file_util_unittest.cc12
-rw-r--r--webkit/fileapi/syncable/syncable_file_system_unittest.cc2
12 files changed, 53 insertions, 70 deletions
diff --git a/webkit/fileapi/file_system_file_util_unittest.cc b/webkit/fileapi/file_system_file_util_unittest.cc
index 7e45cef..b33b32a 100644
--- a/webkit/fileapi/file_system_file_util_unittest.cc
+++ b/webkit/fileapi/file_system_file_util_unittest.cc
@@ -51,16 +51,16 @@ class FileSystemFileUtilTest : public testing::Test {
bool copy) {
base::ScopedTempDir base_dir;
ASSERT_TRUE(base_dir.CreateUniqueTempDir());
- scoped_ptr<ObfuscatedFileUtil> file_util(
- new ObfuscatedFileUtil(base_dir.path()));
LocalFileSystemTestOriginHelper src_helper(src_origin, src_type);
src_helper.SetUp(base_dir.path(),
false, // unlimited quota
- NULL, // quota::QuotaManagerProxy
- file_util.get());
+ NULL); // quota::QuotaManagerProxy
LocalFileSystemTestOriginHelper dest_helper(dest_origin, dest_type);
- dest_helper.SetUp(src_helper.file_system_context(), file_util.get());
+ dest_helper.SetUp(src_helper.file_system_context());
+
+ ObfuscatedFileUtil* file_util = static_cast<ObfuscatedFileUtil*>(
+ src_helper.file_util());
// Set up all the source data.
scoped_ptr<FileSystemOperationContext> context;
diff --git a/webkit/fileapi/file_writer_delegate_unittest.cc b/webkit/fileapi/file_writer_delegate_unittest.cc
index 415c2d9..8a3fdf8 100644
--- a/webkit/fileapi/file_writer_delegate_unittest.cc
+++ b/webkit/fileapi/file_writer_delegate_unittest.cc
@@ -198,7 +198,7 @@ net::URLRequestJob* FileWriterDelegateTest::Factory(
void FileWriterDelegateTest::SetUp() {
ASSERT_TRUE(dir_.CreateUniqueTempDir());
FilePath base_dir = dir_.path().AppendASCII("filesystem");
- test_helper_.SetUp(base_dir, NULL);
+ test_helper_.SetUp(base_dir);
scoped_ptr<FileSystemOperationContext> context(
test_helper_.NewOperationContext());
diff --git a/webkit/fileapi/isolated_file_util_unittest.cc b/webkit/fileapi/isolated_file_util_unittest.cc
index 9a5b48e..b5e77c5 100644
--- a/webkit/fileapi/isolated_file_util_unittest.cc
+++ b/webkit/fileapi/isolated_file_util_unittest.cc
@@ -56,10 +56,12 @@ FilePath GetTopLevelPath(const FilePath& path) {
// IsolatedFileUtil.
class IsolatedFileUtilTest : public testing::Test {
public:
- IsolatedFileUtilTest() {}
+ IsolatedFileUtilTest()
+ : other_file_util_helper_(GURL("http://foo/"), kFileSystemTypeTest) {}
void SetUp() {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
+ ASSERT_TRUE(partition_dir_.CreateUniqueTempDir());
file_util_.reset(new DraggedFileUtil());
// Register the files/directories of RegularTestCases (with random
@@ -70,12 +72,11 @@ class IsolatedFileUtilTest : public testing::Test {
FileSystemTaskRunners::CreateMockTaskRunners(),
make_scoped_refptr(new quota::MockSpecialStoragePolicy()),
NULL /* quota_manager */,
- data_dir_.path(),
+ partition_dir_.path(),
CreateAllowFileAccessOptions());
// For cross-FileUtil copy/move tests.
- other_file_util_.reset(new LocalFileUtil());
- other_file_util_helper_.SetUp(file_system_context_, other_file_util_.get());
+ other_file_util_helper_.SetUp(file_system_context_);
isolated_context()->AddReference(filesystem_id_);
}
@@ -96,7 +97,9 @@ class IsolatedFileUtilTest : public testing::Test {
return file_system_context_.get();
}
FileSystemFileUtil* file_util() const { return file_util_.get(); }
- FileSystemFileUtil* other_file_util() const { return other_file_util_.get(); }
+ FileSystemFileUtil* other_file_util() const {
+ return other_file_util_helper_.file_util();
+ }
std::string filesystem_id() const { return filesystem_id_; }
FilePath GetTestCasePlatformPath(const FilePath::StringType& path) {
@@ -235,12 +238,12 @@ class IsolatedFileUtilTest : public testing::Test {
}
base::ScopedTempDir data_dir_;
+ base::ScopedTempDir partition_dir_;
MessageLoop message_loop_;
std::string filesystem_id_;
scoped_refptr<FileSystemContext> file_system_context_;
std::map<FilePath, FilePath> toplevel_root_map_;
scoped_ptr<IsolatedFileUtil> file_util_;
- scoped_ptr<LocalFileUtil> other_file_util_;
LocalFileSystemTestOriginHelper other_file_util_helper_;
DISALLOW_COPY_AND_ASSIGN(IsolatedFileUtilTest);
};
diff --git a/webkit/fileapi/local_file_system_operation.h b/webkit/fileapi/local_file_system_operation.h
index ebf4356..d6ba7c6 100644
--- a/webkit/fileapi/local_file_system_operation.h
+++ b/webkit/fileapi/local_file_system_operation.h
@@ -122,14 +122,6 @@ class WEBKIT_STORAGE_EXPORT LocalFileSystemOperation
return operation_context_.get();
}
- // The unit tests that need to specify and control the lifetime of the
- // file_util on their own should call this before performing the actual
- // operation. If it is given it will not be overwritten by the class.
- void set_override_file_util(FileSystemFileUtil* file_util) {
- src_util_ = file_util;
- dest_util_ = file_util;
- }
-
// Queries the quota and usage and then runs the given |task|.
// If an error occurs during the quota query it runs |error_callback| instead.
void GetUsageAndQuotaThenRunTask(
diff --git a/webkit/fileapi/local_file_system_operation_unittest.cc b/webkit/fileapi/local_file_system_operation_unittest.cc
index 9aab4d6..604f91d 100644
--- a/webkit/fileapi/local_file_system_operation_unittest.cc
+++ b/webkit/fileapi/local_file_system_operation_unittest.cc
@@ -301,8 +301,7 @@ void LocalFileSystemOperationTest::SetUp() {
base::MessageLoopProxy::current());
test_helper_.SetUp(base_dir,
false /* unlimited quota */,
- quota_manager_proxy_.get(),
- NULL);
+ quota_manager_proxy_.get());
}
void LocalFileSystemOperationTest::TearDown() {
diff --git a/webkit/fileapi/local_file_system_operation_write_unittest.cc b/webkit/fileapi/local_file_system_operation_write_unittest.cc
index 4bf0ed0..4a8cd47 100644
--- a/webkit/fileapi/local_file_system_operation_write_unittest.cc
+++ b/webkit/fileapi/local_file_system_operation_write_unittest.cc
@@ -177,8 +177,7 @@ void LocalFileSystemOperationWriteTest::SetUp() {
quota_manager_ = new MockQuotaManager(base_dir, 1024);
test_helper_.SetUp(base_dir,
false /* unlimited quota */,
- quota_manager_->proxy(),
- NULL);
+ quota_manager_->proxy());
virtual_path_ = FilePath(FILE_PATH_LITERAL("temporary file"));
operation()->CreateFile(
diff --git a/webkit/fileapi/local_file_system_quota_unittest.cc b/webkit/fileapi/local_file_system_quota_unittest.cc
index d91642c..1e7f6a7 100644
--- a/webkit/fileapi/local_file_system_quota_unittest.cc
+++ b/webkit/fileapi/local_file_system_quota_unittest.cc
@@ -198,8 +198,7 @@ void LocalFileSystemQuotaTest::SetUp() {
test_helper_.SetUp(filesystem_dir_path,
false /* unlimited quota */,
- quota_manager_->proxy(),
- NULL);
+ quota_manager_->proxy());
}
void LocalFileSystemQuotaTest::TearDown() {
diff --git a/webkit/fileapi/local_file_system_test_helper.cc b/webkit/fileapi/local_file_system_test_helper.cc
index 2de3aca3..d18249f 100644
--- a/webkit/fileapi/local_file_system_test_helper.cc
+++ b/webkit/fileapi/local_file_system_test_helper.cc
@@ -37,18 +37,15 @@ LocalFileSystemTestOriginHelper::LocalFileSystemTestOriginHelper()
LocalFileSystemTestOriginHelper::~LocalFileSystemTestOriginHelper() {
}
-void LocalFileSystemTestOriginHelper::SetUp(
- const FilePath& base_dir, FileSystemFileUtil* file_util) {
- SetUp(base_dir, false, NULL, file_util);
+void LocalFileSystemTestOriginHelper::SetUp(const FilePath& base_dir) {
+ SetUp(base_dir, false, NULL);
}
void LocalFileSystemTestOriginHelper::SetUp(
- FileSystemContext* file_system_context, FileSystemFileUtil* file_util) {
- file_util_ = file_util;
+ FileSystemContext* file_system_context) {
file_system_context_ = file_system_context;
- if (!file_util_)
- file_util_ = file_system_context->GetFileUtil(type_);
- DCHECK(file_util_);
+
+ SetUpFileUtil();
// Prepare the origin's root directory.
file_system_context_->GetMountPointProvider(type_)->
@@ -64,8 +61,7 @@ void LocalFileSystemTestOriginHelper::SetUp(
void LocalFileSystemTestOriginHelper::SetUp(
const FilePath& base_dir,
bool unlimited_quota,
- quota::QuotaManagerProxy* quota_manager_proxy,
- FileSystemFileUtil* file_util) {
+ quota::QuotaManagerProxy* quota_manager_proxy) {
scoped_refptr<quota::MockSpecialStoragePolicy> special_storage_policy =
new quota::MockSpecialStoragePolicy;
special_storage_policy->SetAllUnlimited(unlimited_quota);
@@ -76,13 +72,7 @@ void LocalFileSystemTestOriginHelper::SetUp(
base_dir,
CreateAllowFileAccessOptions());
- if (type_ == kFileSystemTypeTest) {
- file_system_context_->RegisterMountPointProvider(
- type_,
- new TestMountPointProvider(
- file_system_context_->task_runners()->file_task_runner(),
- base_dir));
- }
+ SetUpFileUtil();
// Prepare the origin's root directory.
FileSystemMountPointProvider* mount_point_provider =
@@ -90,13 +80,6 @@ void LocalFileSystemTestOriginHelper::SetUp(
mount_point_provider->GetFileSystemRootPathOnFileThread(
FileSystemURL(origin_, type_, FilePath()), true /* create */);
- if (file_util)
- file_util_ = file_util;
- else
- file_util_ = mount_point_provider->GetFileUtil(type_);
-
- DCHECK(file_util_);
-
// Initialize the usage cache file.
FilePath usage_cache_path = GetUsageCachePath();
if (!usage_cache_path.empty())
@@ -180,7 +163,6 @@ LocalFileSystemOperation* LocalFileSystemTestOriginHelper::NewOperation() {
LocalFileSystemOperation* operation = static_cast<LocalFileSystemOperation*>(
file_system_context_->CreateFileSystemOperation(
CreateURL(FilePath()), NULL));
- operation->set_override_file_util(file_util_);
return operation;
}
@@ -194,4 +176,20 @@ LocalFileSystemTestOriginHelper::NewOperationContext() {
return context;
}
+void LocalFileSystemTestOriginHelper::SetUpFileUtil() {
+ DCHECK(file_system_context_);
+ if (type_ == kFileSystemTypeTest) {
+ file_system_context_->RegisterMountPointProvider(
+ type_,
+ new TestMountPointProvider(
+ file_system_context_->task_runners()->file_task_runner(),
+ file_system_context_->partition_path()));
+ }
+ FileSystemMountPointProvider* mount_point_provider =
+ file_system_context_->GetMountPointProvider(type_);
+ DCHECK(mount_point_provider);
+ file_util_ = mount_point_provider->GetFileUtil(type_);
+ DCHECK(file_util_);
+}
+
} // namespace fileapi
diff --git a/webkit/fileapi/local_file_system_test_helper.h b/webkit/fileapi/local_file_system_test_helper.h
index 5c5682e..c6cf8c7 100644
--- a/webkit/fileapi/local_file_system_test_helper.h
+++ b/webkit/fileapi/local_file_system_test_helper.h
@@ -37,17 +37,15 @@ class LocalFileSystemTestOriginHelper {
LocalFileSystemTestOriginHelper();
~LocalFileSystemTestOriginHelper();
- void SetUp(const FilePath& base_dir, FileSystemFileUtil* file_util);
+ void SetUp(const FilePath& base_dir);
// If you want to use more than one LocalFileSystemTestOriginHelper in
// a single base directory, they have to share a context, so that they don't
// have multiple databases fighting over the lock to the origin directory
// [deep down inside ObfuscatedFileUtil].
- void SetUp(FileSystemContext* file_system_context,
- FileSystemFileUtil* file_util);
+ void SetUp(FileSystemContext* file_system_context);
void SetUp(const FilePath& base_dir,
bool unlimited_quota,
- quota::QuotaManagerProxy* quota_manager_proxy,
- FileSystemFileUtil* file_util);
+ quota::QuotaManagerProxy* quota_manager_proxy);
void TearDown();
FilePath GetOriginRootPath() const;
@@ -95,6 +93,8 @@ class LocalFileSystemTestOriginHelper {
FileSystemFileUtil* file_util() const { return file_util_; }
private:
+ void SetUpFileUtil();
+
scoped_refptr<FileSystemContext> file_system_context_;
const GURL origin_;
const FileSystemType type_;
diff --git a/webkit/fileapi/local_file_util_unittest.cc b/webkit/fileapi/local_file_util_unittest.cc
index 9d29082..72c9ecb 100644
--- a/webkit/fileapi/local_file_util_unittest.cc
+++ b/webkit/fileapi/local_file_util_unittest.cc
@@ -26,12 +26,11 @@ namespace fileapi {
class LocalFileUtilTest : public testing::Test {
public:
LocalFileUtilTest()
- : local_file_util_(new LocalFileUtil()) {
- }
+ : test_helper_(GURL("http://foo/"), kFileSystemTypeTest) {}
void SetUp() {
ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
- test_helper_.SetUp(data_dir_.path(), FileUtil());
+ test_helper_.SetUp(data_dir_.path());
}
void TearDown() {
@@ -45,7 +44,7 @@ class LocalFileUtilTest : public testing::Test {
}
LocalFileUtil* FileUtil() {
- return local_file_util_.get();
+ return static_cast<LocalFileUtil*>(test_helper_.file_util());
}
FileSystemURL Path(const std::string& file_name) {
diff --git a/webkit/fileapi/obfuscated_file_util_unittest.cc b/webkit/fileapi/obfuscated_file_util_unittest.cc
index 3de146e..fea134e 100644
--- a/webkit/fileapi/obfuscated_file_util_unittest.cc
+++ b/webkit/fileapi/obfuscated_file_util_unittest.cc
@@ -128,11 +128,7 @@ class ObfuscatedFileUtilTest : public testing::Test {
data_dir_.path(),
CreateAllowFileAccessOptions());
- obfuscated_file_util_ = static_cast<ObfuscatedFileUtil*>(
- file_system_context_->GetFileUtil(type_));
-
- test_helper_.SetUp(file_system_context_.get(),
- obfuscated_file_util_);
+ test_helper_.SetUp(file_system_context_.get());
change_observers_ = MockFileChangeObserver::CreateList(&change_observer_);
}
@@ -185,13 +181,12 @@ class ObfuscatedFileUtilTest : public testing::Test {
LocalFileSystemTestOriginHelper* helper =
new LocalFileSystemTestOriginHelper(origin, type);
- helper->SetUp(file_system_context_.get(),
- obfuscated_file_util_);
+ helper->SetUp(file_system_context_.get());
return helper;
}
ObfuscatedFileUtil* ofu() {
- return obfuscated_file_util_;
+ return static_cast<ObfuscatedFileUtil*>(test_helper_.file_util());
}
const FilePath& test_directory() const {
@@ -641,7 +636,6 @@ class ObfuscatedFileUtilTest : public testing::Test {
private:
base::ScopedTempDir data_dir_;
MessageLoop message_loop_;
- ObfuscatedFileUtil* obfuscated_file_util_;
scoped_refptr<quota::QuotaManager> quota_manager_;
scoped_refptr<FileSystemContext> file_system_context_;
GURL origin_;
diff --git a/webkit/fileapi/syncable/syncable_file_system_unittest.cc b/webkit/fileapi/syncable/syncable_file_system_unittest.cc
index 1ba0ef6..7c14aac 100644
--- a/webkit/fileapi/syncable/syncable_file_system_unittest.cc
+++ b/webkit/fileapi/syncable/syncable_file_system_unittest.cc
@@ -243,7 +243,7 @@ TEST_F(SyncableFileSystemTest, DisableDirectoryOperations) {
// Set up another (non-syncable) local file system.
LocalFileSystemTestOriginHelper other_file_system_(GURL("http://foo.com/"),
kFileSystemTypeTemporary);
- other_file_system_.SetUp(file_system_.file_system_context(), NULL);
+ other_file_system_.SetUp(file_system_.file_system_context());
// Create directory '/a' and file '/a/b' in the other file system.
const FileSystemURL kSrcDir = other_file_system_.CreateURLFromUTF8("/a");