| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "base/stl_util.h" | 5 #include "base/stl_util.h" |
| 6 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" | 6 #include "chrome/browser/sync_file_system/local/canned_syncable_file_system.h" |
| 7 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 7 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
| 8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 8 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
| 9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 9 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
| 10 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" | 10 #include "chrome/browser/sync_file_system/syncable_file_system_util.h" |
| 11 #include "content/public/test/sandbox_file_system_test_helper.h" | 11 #include "content/public/test/sandbox_file_system_test_helper.h" |
| 12 #include "content/public/test/test_browser_thread_bundle.h" | 12 #include "content/public/test/test_browser_thread_bundle.h" |
| 13 #include "testing/gtest/include/gtest/gtest.h" | 13 #include "testing/gtest/include/gtest/gtest.h" |
| 14 #include "webkit/browser/fileapi/async_file_test_helper.h" |
| 14 #include "webkit/browser/fileapi/file_system_context.h" | 15 #include "webkit/browser/fileapi/file_system_context.h" |
| 15 #include "webkit/browser/fileapi/file_system_file_util.h" | |
| 16 #include "webkit/browser/fileapi/file_system_operation_context.h" | 16 #include "webkit/browser/fileapi/file_system_operation_context.h" |
| 17 #include "webkit/browser/fileapi/isolated_context.h" | 17 #include "webkit/browser/fileapi/isolated_context.h" |
| 18 #include "webkit/browser/quota/quota_manager.h" | 18 #include "webkit/browser/quota/quota_manager.h" |
| 19 #include "webkit/common/fileapi/file_system_types.h" | 19 #include "webkit/common/fileapi/file_system_types.h" |
| 20 #include "webkit/common/quota/quota_types.h" | 20 #include "webkit/common/quota/quota_types.h" |
| 21 | 21 |
| 22 using base::PlatformFileError; | 22 using base::PlatformFileError; |
| 23 using fileapi::FileSystemContext; | 23 using fileapi::FileSystemContext; |
| 24 using fileapi::FileSystemOperationContext; | 24 using fileapi::FileSystemOperationContext; |
| 25 using fileapi::FileSystemURL; | 25 using fileapi::FileSystemURL; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 258 | 258 |
| 259 // Set up another (non-syncable) local file system. | 259 // Set up another (non-syncable) local file system. |
| 260 SandboxFileSystemTestHelper other_file_system_( | 260 SandboxFileSystemTestHelper other_file_system_( |
| 261 GURL("http://foo.com/"), fileapi::kFileSystemTypeTemporary); | 261 GURL("http://foo.com/"), fileapi::kFileSystemTypeTemporary); |
| 262 other_file_system_.SetUp(file_system_.file_system_context()); | 262 other_file_system_.SetUp(file_system_.file_system_context()); |
| 263 | 263 |
| 264 // Create directory '/a' and file '/a/b' in the other file system. | 264 // Create directory '/a' and file '/a/b' in the other file system. |
| 265 const FileSystemURL kSrcDir = other_file_system_.CreateURLFromUTF8("/a"); | 265 const FileSystemURL kSrcDir = other_file_system_.CreateURLFromUTF8("/a"); |
| 266 const FileSystemURL kSrcChild = other_file_system_.CreateURLFromUTF8("/a/b"); | 266 const FileSystemURL kSrcChild = other_file_system_.CreateURLFromUTF8("/a/b"); |
| 267 | 267 |
| 268 bool created = false; | |
| 269 scoped_ptr<FileSystemOperationContext> operation_context; | |
| 270 | |
| 271 operation_context.reset(other_file_system_.NewOperationContext()); | |
| 272 operation_context->set_allowed_bytes_growth(1024); | |
| 273 EXPECT_EQ(base::PLATFORM_FILE_OK, | 268 EXPECT_EQ(base::PLATFORM_FILE_OK, |
| 274 other_file_system_.file_util()->CreateDirectory( | 269 fileapi::AsyncFileTestHelper::CreateDirectory( |
| 275 operation_context.get(), | 270 other_file_system_.file_system_context(), kSrcDir)); |
| 276 kSrcDir, false /* exclusive */, false /* recursive */)); | |
| 277 | |
| 278 operation_context.reset(other_file_system_.NewOperationContext()); | |
| 279 operation_context->set_allowed_bytes_growth(1024); | |
| 280 EXPECT_EQ(base::PLATFORM_FILE_OK, | 271 EXPECT_EQ(base::PLATFORM_FILE_OK, |
| 281 other_file_system_.file_util()->EnsureFileExists( | 272 fileapi::AsyncFileTestHelper::CreateFile( |
| 282 operation_context.get(), kSrcChild, &created)); | 273 other_file_system_.file_system_context(), kSrcChild)); |
| 283 EXPECT_TRUE(created); | |
| 284 | 274 |
| 285 // Now try copying the directory into the syncable file system, which should | 275 // Now try copying the directory into the syncable file system, which should |
| 286 // fail if directory operation is disabled. (http://crbug.com/161442) | 276 // fail if directory operation is disabled. (http://crbug.com/161442) |
| 287 EXPECT_NE(base::PLATFORM_FILE_OK, | 277 EXPECT_NE(base::PLATFORM_FILE_OK, |
| 288 file_system_.Copy(kSrcDir, URL("dest"))); | 278 file_system_.Copy(kSrcDir, URL("dest"))); |
| 289 | 279 |
| 290 other_file_system_.TearDown(); | 280 other_file_system_.TearDown(); |
| 291 SetEnableSyncFSDirectoryOperation(was_enabled); | 281 SetEnableSyncFSDirectoryOperation(was_enabled); |
| 292 } | 282 } |
| 293 | 283 |
| 294 } // namespace sync_file_system | 284 } // namespace sync_file_system |
| OLD | NEW |