Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Unified Diff: webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc

Issue 21097005: Fix up some tests for copy-or-move validator and nearby. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: enum simplification Created 7 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc
diff --git a/webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc b/webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc
index 95e73c6c0d041991e93811dd0576e0116e879dd4..183becd7dbf2d34490f0b82aca856d531064bc77 100644
--- a/webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc
+++ b/webkit/browser/fileapi/copy_or_move_operation_delegate_unittest.cc
@@ -46,6 +46,7 @@ class TestValidatorFactory : public CopyOrMoveFileValidatorFactory {
virtual CopyOrMoveFileValidator* CreateCopyOrMoveFileValidator(
const FileSystemURL& /*src_url*/,
const base::FilePath& /*platform_path*/) OVERRIDE {
+ // Move arg management to TestValidator?
return new TestValidator(true, true, std::string("2"));
}
@@ -113,6 +114,15 @@ class CopyOrMoveOperationTestHelper {
}
void SetUp() {
+ SetUp(true, true);
+ }
+
+ void SetUpNoValidator() {
+ SetUp(true, false);
+ }
+
+ void SetUp(bool require_copy_or_move_validator,
+ bool init_copy_or_move_validator) {
ASSERT_TRUE(base_.CreateUniqueTempDir());
base::FilePath base_dir = base_.path();
quota_manager_ =
@@ -138,8 +148,10 @@ class CopyOrMoveOperationTestHelper {
static_cast<TestFileSystemBackend*>(backend);
scoped_ptr<CopyOrMoveFileValidatorFactory> factory(
new TestValidatorFactory);
- test_backend->set_require_copy_or_move_validator(true);
- test_backend->InitializeCopyOrMoveFileValidatorFactory(factory.Pass());
+ test_backend->set_require_copy_or_move_validator(
+ require_copy_or_move_validator);
+ if (init_copy_or_move_validator)
+ test_backend->InitializeCopyOrMoveFileValidatorFactory(factory.Pass());
}
backend->OpenFileSystem(origin_, dest_type_,
OPEN_FILE_SYSTEM_CREATE_IF_NONEXISTENT,
@@ -529,4 +541,22 @@ TEST(LocalFileSystemCopyOrMoveOperationTest,
arraysize(kMoveDirResultCases));
}
+TEST(LocalFileSystemCopyOrMoveOperationTest, CopySingleFileNoValidator) {
+ CopyOrMoveOperationTestHelper helper(GURL("http://foo"),
+ kFileSystemTypeTemporary,
+ kFileSystemTypeTest);
+ helper.SetUpNoValidator();
+
+ FileSystemURL src = helper.SourceURL("a");
+ FileSystemURL dest = helper.DestURL("b");
+
+ // Set up a source file.
+ ASSERT_EQ(base::PLATFORM_FILE_OK, helper.CreateFile(src, 10));
+
+ // The copy attempt should fail with a security error -- getting
+ // the factory returns a security error, and the copy operation must
+ // respect that.
+ ASSERT_EQ(base::PLATFORM_FILE_ERROR_SECURITY, helper.Copy(src, dest));
+}
+
} // namespace fileapi
« no previous file with comments | « webkit/browser/fileapi/copy_or_move_operation_delegate.cc ('k') | webkit/browser/fileapi/test_file_system_backend.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698