summaryrefslogtreecommitdiffstats
path: root/webkit/fileapi
diff options
context:
space:
mode:
authordmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 09:00:48 +0000
committerdmikurube@chromium.org <dmikurube@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-04-13 09:00:48 +0000
commitf3feb226ef91ab40a937c425a21b9575509fac57 (patch)
treed1f39024dfaeb1c37363e93b950d588af3ee2fef /webkit/fileapi
parent25e7d3b10563197197a65f86ad26f9cb1a960128 (diff)
downloadchromium_src-f3feb226ef91ab40a937c425a21b9575509fac57.zip
chromium_src-f3feb226ef91ab40a937c425a21b9575509fac57.tar.gz
chromium_src-f3feb226ef91ab40a937c425a21b9575509fac57.tar.bz2
Fix FileSystemOperationTest for writing operations to avoid conflicting class names.
BUG=none TEST=FileSystemOperationWriteTest.* Review URL: http://codereview.chromium.org/6835015 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@81382 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/fileapi')
-rw-r--r--webkit/fileapi/file_system_operation.h1
-rw-r--r--webkit/fileapi/file_system_operation_write_unittest.cc75
2 files changed, 41 insertions, 35 deletions
diff --git a/webkit/fileapi/file_system_operation.h b/webkit/fileapi/file_system_operation.h
index f6d2016..5ba585e 100644
--- a/webkit/fileapi/file_system_operation.h
+++ b/webkit/fileapi/file_system_operation.h
@@ -94,6 +94,7 @@ class FileSystemOperation {
return &file_system_operation_context_;
}
friend class FileSystemOperationTest;
+ friend class FileSystemOperationWriteTest;
// A callback used for OpenFileSystem.
void DidGetRootPath(bool success,
diff --git a/webkit/fileapi/file_system_operation_write_unittest.cc b/webkit/fileapi/file_system_operation_write_unittest.cc
index e331338..57f72fc 100644
--- a/webkit/fileapi/file_system_operation_write_unittest.cc
+++ b/webkit/fileapi/file_system_operation_write_unittest.cc
@@ -27,33 +27,13 @@
#include "webkit/fileapi/file_system_file_util.h"
namespace fileapi {
-
-class TestURLRequestContext : public net::URLRequestContext {
- public:
- webkit_blob::BlobStorageController* blob_storage_controller() {
- return &blob_storage_controller_;
- }
-
- private:
- webkit_blob::BlobStorageController blob_storage_controller_;
-};
-
-static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request,
- const std::string& scheme) {
- webkit_blob::BlobStorageController* blob_storage_controller =
- static_cast<TestURLRequestContext*>(request->context())->
- blob_storage_controller();
- return new webkit_blob::BlobURLRequestJob(
- request,
- blob_storage_controller->GetBlobDataFromUrl(request->url()),
- base::MessageLoopProxy::CreateForCurrentThread());
-}
-
+namespace {
class MockDispatcher;
+} // namespace (anonymous)
-class FileSystemOperationTest : public testing::Test {
+class FileSystemOperationWriteTest : public testing::Test {
public:
- FileSystemOperationTest()
+ FileSystemOperationWriteTest()
: loop_(MessageLoop::TYPE_IO),
status_(base::PLATFORM_FILE_OK),
bytes_written_(0),
@@ -91,12 +71,35 @@ class FileSystemOperationTest : public testing::Test {
int64 bytes_written_;
bool complete_;
- DISALLOW_COPY_AND_ASSIGN(FileSystemOperationTest);
+ DISALLOW_COPY_AND_ASSIGN(FileSystemOperationWriteTest);
};
+namespace {
+
+class TestURLRequestContext : public net::URLRequestContext {
+ public:
+ webkit_blob::BlobStorageController* blob_storage_controller() {
+ return &blob_storage_controller_;
+ }
+
+ private:
+ webkit_blob::BlobStorageController blob_storage_controller_;
+};
+
+static net::URLRequestJob* BlobURLRequestJobFactory(net::URLRequest* request,
+ const std::string& scheme) {
+ webkit_blob::BlobStorageController* blob_storage_controller =
+ static_cast<TestURLRequestContext*>(request->context())->
+ blob_storage_controller();
+ return new webkit_blob::BlobURLRequestJob(
+ request,
+ blob_storage_controller->GetBlobDataFromUrl(request->url()),
+ base::MessageLoopProxy::CreateForCurrentThread());
+}
+
class MockDispatcher : public FileSystemCallbackDispatcher {
public:
- MockDispatcher(FileSystemOperationTest* test) : test_(test) { }
+ MockDispatcher(FileSystemOperationWriteTest* test) : test_(test) { }
virtual void DidFail(base::PlatformFileError status) {
test_->set_failure_status(status);
@@ -129,20 +132,22 @@ class MockDispatcher : public FileSystemCallbackDispatcher {
}
private:
- FileSystemOperationTest* test_;
+ FileSystemOperationWriteTest* test_;
};
-void FileSystemOperationTest::SetUp() {
+} // namespace (anonymous)
+
+void FileSystemOperationWriteTest::SetUp() {
ASSERT_TRUE(dir_.CreateUniqueTempDir());
file_util::CreateTemporaryFileInDir(dir_.path(), &file_);
net::URLRequest::RegisterProtocolFactory("blob", &BlobURLRequestJobFactory);
}
-void FileSystemOperationTest::TearDown() {
+void FileSystemOperationWriteTest::TearDown() {
net::URLRequest::RegisterProtocolFactory("blob", NULL);
}
-FileSystemOperation* FileSystemOperationTest::operation() {
+FileSystemOperation* FileSystemOperationWriteTest::operation() {
FileSystemOperation* operation = new FileSystemOperation(
new MockDispatcher(this),
base::MessageLoopProxy::CreateForCurrentThread(),
@@ -155,7 +160,7 @@ FileSystemOperation* FileSystemOperationTest::operation() {
return operation;
}
-TEST_F(FileSystemOperationTest, TestWriteSuccess) {
+TEST_F(FileSystemOperationWriteTest, TestWriteSuccess) {
GURL blob_url("blob:success");
scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData());
blob_data->AppendData("Hello, world!\n");
@@ -175,7 +180,7 @@ TEST_F(FileSystemOperationTest, TestWriteSuccess) {
EXPECT_TRUE(complete());
}
-TEST_F(FileSystemOperationTest, TestWriteZero) {
+TEST_F(FileSystemOperationWriteTest, TestWriteZero) {
GURL blob_url("blob:zero");
scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData());
blob_data->AppendData("");
@@ -195,7 +200,7 @@ TEST_F(FileSystemOperationTest, TestWriteZero) {
EXPECT_TRUE(complete());
}
-TEST_F(FileSystemOperationTest, TestWriteInvalidBlobUrl) {
+TEST_F(FileSystemOperationWriteTest, TestWriteInvalidBlobUrl) {
scoped_refptr<TestURLRequestContext> url_request_context(
new TestURLRequestContext());
@@ -207,7 +212,7 @@ TEST_F(FileSystemOperationTest, TestWriteInvalidBlobUrl) {
EXPECT_TRUE(complete());
}
-TEST_F(FileSystemOperationTest, TestWriteInvalidFile) {
+TEST_F(FileSystemOperationWriteTest, TestWriteInvalidFile) {
GURL blob_url("blob:writeinvalidfile");
scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData());
blob_data->AppendData("It\'ll not be written.");
@@ -228,7 +233,7 @@ TEST_F(FileSystemOperationTest, TestWriteInvalidFile) {
EXPECT_TRUE(complete());
}
-TEST_F(FileSystemOperationTest, TestWriteDir) {
+TEST_F(FileSystemOperationWriteTest, TestWriteDir) {
GURL blob_url("blob:writedir");
scoped_refptr<webkit_blob::BlobData> blob_data(new webkit_blob::BlobData());
blob_data->AppendData("It\'ll not be written, too.");