| OLD | NEW | 
|---|
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 "webkit/browser/fileapi/file_system_context.h" | 5 #include "webkit/browser/fileapi/file_system_context.h" | 
| 6 | 6 | 
| 7 #include "base/files/scoped_temp_dir.h" | 7 #include "base/files/scoped_temp_dir.h" | 
| 8 #include "base/message_loop.h" | 8 #include "base/message_loop.h" | 
| 9 #include "base/stringprintf.h" | 9 #include "base/stringprintf.h" | 
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" | 
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 42 | 42 | 
| 43 class FileSystemContextTest : public testing::Test { | 43 class FileSystemContextTest : public testing::Test { | 
| 44  public: | 44  public: | 
| 45   FileSystemContextTest() {} | 45   FileSystemContextTest() {} | 
| 46 | 46 | 
| 47   virtual void SetUp() { | 47   virtual void SetUp() { | 
| 48     ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 48     ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); | 
| 49 | 49 | 
| 50     storage_policy_ = new quota::MockSpecialStoragePolicy(); | 50     storage_policy_ = new quota::MockSpecialStoragePolicy(); | 
| 51 | 51 | 
| 52     mock_quota_manager_ = new quota::MockQuotaManager( | 52     mock_quota_manager_ = | 
| 53         false /* is_incognito */, | 53         new quota::MockQuotaManager(false /* is_incognito */, | 
| 54         data_dir_.path(), | 54                                     data_dir_.path(), | 
| 55         base::MessageLoopProxy::current(), | 55                                     base::MessageLoopProxy::current(), | 
| 56         base::MessageLoopProxy::current(), | 56                                     base::MessageLoopProxy::current(), | 
| 57         storage_policy_); | 57                                     storage_policy_.get()); | 
| 58   } | 58   } | 
| 59 | 59 | 
| 60  protected: | 60  protected: | 
| 61   FileSystemContext* CreateFileSystemContextForTest( | 61   FileSystemContext* CreateFileSystemContextForTest( | 
| 62       ExternalMountPoints* external_mount_points) { | 62       ExternalMountPoints* external_mount_points) { | 
| 63     return new FileSystemContext( | 63     return new FileSystemContext(FileSystemTaskRunners::CreateMockTaskRunners(), | 
| 64         FileSystemTaskRunners::CreateMockTaskRunners(), | 64                                  external_mount_points, | 
| 65         external_mount_points, | 65                                  storage_policy_.get(), | 
| 66         storage_policy_, | 66                                  mock_quota_manager_->proxy(), | 
| 67         mock_quota_manager_->proxy(), | 67                                  ScopedVector<FileSystemMountPointProvider>(), | 
| 68         ScopedVector<FileSystemMountPointProvider>(), | 68                                  data_dir_.path(), | 
| 69         data_dir_.path(), | 69                                  CreateAllowFileAccessOptions()); | 
| 70         CreateAllowFileAccessOptions()); |  | 
| 71   } | 70   } | 
| 72 | 71 | 
| 73   // Verifies a *valid* filesystem url has expected values. | 72   // Verifies a *valid* filesystem url has expected values. | 
| 74   void ExpectFileSystemURLMatches(const FileSystemURL& url, | 73   void ExpectFileSystemURLMatches(const FileSystemURL& url, | 
| 75                                   const GURL& expect_origin, | 74                                   const GURL& expect_origin, | 
| 76                                   FileSystemType expect_mount_type, | 75                                   FileSystemType expect_mount_type, | 
| 77                                   FileSystemType expect_type, | 76                                   FileSystemType expect_type, | 
| 78                                   const base::FilePath& expect_path, | 77                                   const base::FilePath& expect_path, | 
| 79                                   const base::FilePath& expect_virtual_path, | 78                                   const base::FilePath& expect_virtual_path, | 
| 80                                   const std::string& expect_filesystem_id) { | 79                                   const std::string& expect_filesystem_id) { | 
| (...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 179       "system"); | 178       "system"); | 
| 180 | 179 | 
| 181   // No need to revoke the registered filesystem since |mount_points| lifetime | 180   // No need to revoke the registered filesystem since |mount_points| lifetime | 
| 182   // is bound to this test. | 181   // is bound to this test. | 
| 183 } | 182 } | 
| 184 | 183 | 
| 185 TEST_F(FileSystemContextTest, CrackFileSystemURL) { | 184 TEST_F(FileSystemContextTest, CrackFileSystemURL) { | 
| 186   scoped_refptr<ExternalMountPoints> external_mount_points( | 185   scoped_refptr<ExternalMountPoints> external_mount_points( | 
| 187       ExternalMountPoints::CreateRefCounted()); | 186       ExternalMountPoints::CreateRefCounted()); | 
| 188   scoped_refptr<FileSystemContext> file_system_context( | 187   scoped_refptr<FileSystemContext> file_system_context( | 
| 189       CreateFileSystemContextForTest(external_mount_points)); | 188       CreateFileSystemContextForTest(external_mount_points.get())); | 
| 190 | 189 | 
| 191   // Register an isolated mount point. | 190   // Register an isolated mount point. | 
| 192   std::string isolated_file_system_name = "root"; | 191   std::string isolated_file_system_name = "root"; | 
| 193   const std::string kIsolatedFileSystemID = | 192   const std::string kIsolatedFileSystemID = | 
| 194       IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 193       IsolatedContext::GetInstance()->RegisterFileSystemForPath( | 
| 195           kFileSystemTypeNativeLocal, | 194           kFileSystemTypeNativeLocal, | 
| 196           base::FilePath(DRIVE FPL("/test/isolated/root")), | 195           base::FilePath(DRIVE FPL("/test/isolated/root")), | 
| 197           &isolated_file_system_name); | 196           &isolated_file_system_name); | 
| 198   // Register system external mount point. | 197   // Register system external mount point. | 
| 199   ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 198   ASSERT_TRUE(ExternalMountPoints::GetSystemInstance()->RegisterFileSystem( | 
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 320       base::FilePath(DRIVE FPL("/test/isolated/root"))); | 319       base::FilePath(DRIVE FPL("/test/isolated/root"))); | 
| 321   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); | 320   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); | 
| 322   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext"); | 321   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext"); | 
| 323   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 322   ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( | 
| 324       kIsolatedFileSystemID); | 323       kIsolatedFileSystemID); | 
| 325 } | 324 } | 
| 326 | 325 | 
| 327 }  // namespace | 326 }  // namespace | 
| 328 | 327 | 
| 329 }  // namespace fileapi | 328 }  // namespace fileapi | 
| OLD | NEW | 
|---|