summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi/file_system_operation_unittest.cc
diff options
context:
space:
mode:
authorericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 01:58:45 +0000
committerericu@google.com <ericu@google.com@0039d316-1c4b-4281-b951-d872f2087c98>2010-10-05 01:58:45 +0000
commitc9f87ae7ddfa0fc8ca2d20a91572198c42b81b18 (patch)
treeb3cc1f0564805e9cd085aebe860fffe4a2a20b5a /webkit/fileapi/file_system_operation_unittest.cc
parent43fad839433bfa7561f86e0f4629f5a9b2b31b3e (diff)
downloadchromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.zip
chromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.tar.gz
chromium_src-c9f87ae7ddfa0fc8ca2d20a91572198c42b81b18.tar.bz2
Revert 61462 - Add truncate and cancel for FileWriter; write and more tests will come in later CLs.
This CL also contains a fair amount of plumbing for the write call itself. BUG=none TEST=none Review URL: http://codereview.chromium.org/3599011 TBR=ericu@google.com Review URL: http://codereview.chromium.org/3604006 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@61463 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi/file_system_operation_unittest.cc')
-rw-r--r--webkit/fileapi/file_system_operation_unittest.cc58
1 files changed, 0 insertions, 58 deletions
diff --git a/webkit/fileapi/file_system_operation_unittest.cc b/webkit/fileapi/file_system_operation_unittest.cc
index 9148811..93680a0 100644
--- a/webkit/fileapi/file_system_operation_unittest.cc
+++ b/webkit/fileapi/file_system_operation_unittest.cc
@@ -52,10 +52,6 @@ class MockDispatcher : public fileapi::FileSystemCallbackDispatcher {
NOTREACHED();
}
- virtual void DidWrite(int64 bytes, bool complete) {
- NOTREACHED();
- }
-
// Helpers for testing.
int status() const { return status_; }
int request_id() const { return request_id_; }
@@ -557,57 +553,3 @@ TEST_F(FileSystemOperationTest, TestRemoveSuccess) {
EXPECT_FALSE(file_util::DirectoryExists(empty_dir.path()));
EXPECT_EQ(request_id_, mock_dispatcher_->request_id());
}
-
-TEST_F(FileSystemOperationTest, TestTruncate) {
- ScopedTempDir dir;
- ASSERT_TRUE(dir.CreateUniqueTempDir());
- FilePath file;
- file_util::CreateTemporaryFileInDir(dir.path(), &file);
-
- char test_data[] = "test data";
- EXPECT_EQ(sizeof(test_data),
- file_util::WriteFile(file, test_data, sizeof(test_data)));
-
- // Check that its length is the size of the data written.
- operation()->GetMetadata(file);
- MessageLoop::current()->RunAllPending();
- EXPECT_EQ(kFileOperationSucceeded, mock_dispatcher_->status());
- EXPECT_FALSE(mock_dispatcher_->info().is_directory);
- EXPECT_EQ(sizeof(test_data), mock_dispatcher_->info().size);
- EXPECT_EQ(request_id_, mock_dispatcher_->request_id());
-
- // Extend the file by truncating it.
- int length = 17;
- operation()->Truncate(file, length);
- MessageLoop::current()->RunAllPending();
- EXPECT_EQ(kFileOperationSucceeded, mock_dispatcher_->status());
- EXPECT_EQ(request_id_, mock_dispatcher_->request_id());
-
- // Check that its length is now 17 and that it's all zeroes after the test
- // data.
- base::PlatformFileInfo info;
- EXPECT_TRUE(file_util::GetFileInfo(file, &info));
- EXPECT_EQ(length, info.size);
- char data[100];
- EXPECT_EQ(length, file_util::ReadFile(file, data, length));
- for (int i = 0; i < length; ++i) {
- if (i < sizeof(test_data))
- EXPECT_EQ(test_data[i], data[i]);
- else
- EXPECT_EQ(0, data[i]);
- }
-
- // Shorten the file by truncating it.
- length = 3;
- operation()->Truncate(file, length);
- MessageLoop::current()->RunAllPending();
- EXPECT_EQ(kFileOperationSucceeded, mock_dispatcher_->status());
- EXPECT_EQ(request_id_, mock_dispatcher_->request_id());
-
- // Check that its length is now 3 and that it contains only bits of test data.
- EXPECT_TRUE(file_util::GetFileInfo(file, &info));
- EXPECT_EQ(length, info.size);
- EXPECT_EQ(length, file_util::ReadFile(file, data, length));
- for (int i = 0; i < length; ++i)
- EXPECT_EQ(test_data[i], data[i]);
-}