Chromium Code Reviews| Index: webkit/fileapi/file_system_quota_unittest.cc |
| diff --git a/webkit/fileapi/file_system_quota_unittest.cc b/webkit/fileapi/file_system_quota_unittest.cc |
| index 4c1d25941496914640396dd49f1193ffa939d537..ec3db893071bf999e46ca284f95eb3eb186041af 100644 |
| --- a/webkit/fileapi/file_system_quota_unittest.cc |
| +++ b/webkit/fileapi/file_system_quota_unittest.cc |
| @@ -15,7 +15,6 @@ |
| #include "base/platform_file.h" |
| #include "base/scoped_temp_dir.h" |
| #include "testing/gtest/include/gtest/gtest.h" |
| -#include "webkit/fileapi/file_system_callback_dispatcher.h" |
| #include "webkit/fileapi/file_system_operation.h" |
| #include "webkit/fileapi/file_system_test_helper.h" |
| #include "webkit/fileapi/file_system_usage_cache.h" |
| @@ -116,6 +115,15 @@ class FileSystemQuotaTest : public testing::Test { |
| FilePath grandchild_file2_path_; |
| protected: |
| + // Callback for recording test results. |
| + FileSystemOperationInterface::StatusCallback RecordStatus() { |
|
kinuko
2012/02/10 05:34:09
ditto.
kinaba
2012/02/10 08:22:58
Done.
|
| + return base::Bind(&FileSystemQuotaTest::DidFinish, base::Unretained(this)); |
| + } |
| + |
| + void DidFinish(base::PlatformFileError status) { |
| + set_status(status); |
| + } |
| + |
| FileSystemTestOriginHelper test_helper_; |
| ScopedTempDir work_dir_; |
| @@ -146,50 +154,6 @@ class FileSystemObfuscatedQuotaTest : public FileSystemQuotaTest { |
| scoped_refptr<FileSystemContext> file_system_context_; |
| }; |
| -namespace { |
| - |
| -class MockDispatcher : public FileSystemCallbackDispatcher { |
| - public: |
| - explicit MockDispatcher(FileSystemQuotaTest* test) : test_(test) { } |
| - |
| - virtual void DidFail(base::PlatformFileError status) { |
| - test_->set_status(status); |
| - } |
| - |
| - virtual void DidSucceed() { |
| - test_->set_status(base::PLATFORM_FILE_OK); |
| - } |
| - |
| - virtual void DidGetLocalPath(const FilePath& local_path) { |
| - ADD_FAILURE(); |
| - } |
| - |
| - virtual void DidReadMetadata( |
| - const base::PlatformFileInfo& info, |
| - const FilePath& platform_path) { |
| - ADD_FAILURE(); |
| - } |
| - |
| - virtual void DidReadDirectory( |
| - const std::vector<base::FileUtilProxy::Entry>& entries, |
| - bool /* has_more */) { |
| - ADD_FAILURE(); |
| - } |
| - |
| - virtual void DidOpenFileSystem(const std::string&, const GURL&) { |
| - ADD_FAILURE(); |
| - } |
| - |
| - virtual void DidWrite(int64 bytes, bool complete) { |
| - ADD_FAILURE(); |
| - } |
| - |
| - private: |
| - FileSystemQuotaTest* test_; |
| -}; |
| - |
| -} // namespace (anonymous) |
| - |
| void FileSystemQuotaTest::SetUp() { |
| ASSERT_TRUE(work_dir_.CreateUniqueTempDir()); |
| FilePath filesystem_dir_path = work_dir_.path().AppendASCII("filesystem"); |
| @@ -214,7 +178,7 @@ void FileSystemQuotaTest::TearDown() { |
| } |
| FileSystemOperation* FileSystemQuotaTest::operation() { |
| - return test_helper_.NewOperation(new MockDispatcher(this)); |
| + return test_helper_.NewOperation(); |
| } |
| void FileSystemQuotaTest::OnGetUsageAndQuota( |
| @@ -239,10 +203,10 @@ TEST_F(FileSystemQuotaTest, TestMoveSuccessSrcDirRecursive) { |
| EXPECT_EQ(0, ActualSize()); |
| - operation()->Truncate(URLForPath(child_file1_path_), 5000); |
| - operation()->Truncate(URLForPath(child_file2_path_), 400); |
| - operation()->Truncate(URLForPath(grandchild_file1_path_), 30); |
| - operation()->Truncate(URLForPath(grandchild_file2_path_), 2); |
| + operation()->Truncate(URLForPath(child_file1_path_), 5000, RecordStatus()); |
| + operation()->Truncate(URLForPath(child_file2_path_), 400, RecordStatus()); |
| + operation()->Truncate(URLForPath(grandchild_file1_path_), 30, RecordStatus()); |
| + operation()->Truncate(URLForPath(grandchild_file2_path_), 2, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| const int64 all_file_size = 5000 + 400 + 30 + 2; |
| @@ -254,7 +218,8 @@ TEST_F(FileSystemQuotaTest, TestMoveSuccessSrcDirRecursive) { |
| EXPECT_EQ(all_file_size, usage()); |
| ASSERT_LT(all_file_size, quota()); |
| - operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path)); |
| + operation()->Move(URLForPath(src_dir_path), URLForPath(dest_dir_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| @@ -280,10 +245,10 @@ TEST_F(FileSystemQuotaTest, TestCopySuccessSrcDirRecursive) { |
| EXPECT_EQ(0, ActualSize()); |
| - operation()->Truncate(URLForPath(child_file1_path_), 8000); |
| - operation()->Truncate(URLForPath(child_file2_path_), 700); |
| - operation()->Truncate(URLForPath(grandchild_file1_path_), 60); |
| - operation()->Truncate(URLForPath(grandchild_file2_path_), 5); |
| + operation()->Truncate(URLForPath(child_file1_path_), 8000, RecordStatus()); |
| + operation()->Truncate(URLForPath(child_file2_path_), 700, RecordStatus()); |
| + operation()->Truncate(URLForPath(grandchild_file1_path_), 60, RecordStatus()); |
| + operation()->Truncate(URLForPath(grandchild_file2_path_), 5, RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| const int64 child_file_size = 8000 + 700; |
| @@ -297,7 +262,8 @@ TEST_F(FileSystemQuotaTest, TestCopySuccessSrcDirRecursive) { |
| EXPECT_EQ(all_file_size, usage()); |
| ASSERT_LT(all_file_size, quota()); |
| - operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir1_path)); |
| + operation()->Copy(URLForPath(src_dir_path), URLForPath(dest_dir1_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |
| @@ -320,7 +286,8 @@ TEST_F(FileSystemQuotaTest, TestCopySuccessSrcDirRecursive) { |
| EXPECT_EQ(2 * all_file_size, usage()); |
| ASSERT_LT(2 * all_file_size, quota()); |
| - operation()->Copy(URLForPath(child_dir_path_), URLForPath(dest_dir2_path)); |
| + operation()->Copy(URLForPath(child_dir_path_), URLForPath(dest_dir2_path), |
| + RecordStatus()); |
| MessageLoop::current()->RunAllPending(); |
| EXPECT_EQ(base::PLATFORM_FILE_OK, status()); |