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

Side by Side Diff: webkit/fileapi/file_system_context_unittest.cc

Issue 14096022: Make MountPointProvider pluggable from outside webkit/fileapi (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 8 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
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/fileapi/file_system_context.h" 5 #include "webkit/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"
11 #include "webkit/fileapi/external_mount_points.h" 11 #include "webkit/fileapi/external_mount_points.h"
12 #include "webkit/fileapi/file_system_mount_point_provider.h"
12 #include "webkit/fileapi/file_system_task_runners.h" 13 #include "webkit/fileapi/file_system_task_runners.h"
13 #include "webkit/fileapi/isolated_context.h" 14 #include "webkit/fileapi/isolated_context.h"
14 #include "webkit/fileapi/mock_file_system_options.h" 15 #include "webkit/fileapi/mock_file_system_options.h"
15 #include "webkit/quota/mock_quota_manager.h" 16 #include "webkit/quota/mock_quota_manager.h"
16 #include "webkit/quota/mock_special_storage_policy.h" 17 #include "webkit/quota/mock_special_storage_policy.h"
17 18
18 #define FPL(x) FILE_PATH_LITERAL(x) 19 #define FPL(x) FILE_PATH_LITERAL(x)
19 20
20 #if defined(FILE_PATH_USES_DRIVE_LETTERS) 21 #if defined(FILE_PATH_USES_DRIVE_LETTERS)
21 #define DRIVE FPL("C:") 22 #define DRIVE FPL("C:")
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 base::MessageLoopProxy::current(), 56 base::MessageLoopProxy::current(),
56 storage_policy_); 57 storage_policy_);
57 } 58 }
58 59
59 protected: 60 protected:
60 FileSystemContext* CreateFileSystemContextForTest( 61 FileSystemContext* CreateFileSystemContextForTest(
61 ExternalMountPoints* external_mount_points) { 62 ExternalMountPoints* external_mount_points) {
62 return new FileSystemContext( 63 return new FileSystemContext(
63 FileSystemTaskRunners::CreateMockTaskRunners(), 64 FileSystemTaskRunners::CreateMockTaskRunners(),
64 external_mount_points, 65 external_mount_points,
65 storage_policy_, 66 make_scoped_refptr(new quota::MockSpecialStoragePolicy()),
kinuko 2013/04/17 14:27:29 Will revert this change back to storage_policy_
66 mock_quota_manager_->proxy(), 67 mock_quota_manager_->proxy(),
68 ScopedVector<FileSystemMountPointProvider>(),
67 data_dir_.path(), 69 data_dir_.path(),
68 CreateAllowFileAccessOptions()); 70 CreateAllowFileAccessOptions());
69 } 71 }
70 72
71 // Verifies a *valid* filesystem url has expected values. 73 // Verifies a *valid* filesystem url has expected values.
72 void ExpectFileSystemURLMatches(const FileSystemURL& url, 74 void ExpectFileSystemURLMatches(const FileSystemURL& url,
73 const GURL& expect_origin, 75 const GURL& expect_origin,
74 FileSystemType expect_mount_type, 76 FileSystemType expect_mount_type,
75 FileSystemType expect_type, 77 FileSystemType expect_type,
76 const base::FilePath& expect_path, 78 const base::FilePath& expect_path,
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
127 isolated_id); 129 isolated_id);
128 130
129 FileSystemURL cracked_external = file_system_context->CrackURL( 131 FileSystemURL cracked_external = file_system_context->CrackURL(
130 CreateRawFileSystemURL("external", "system")); 132 CreateRawFileSystemURL("external", "system"));
131 133
132 ExpectFileSystemURLMatches( 134 ExpectFileSystemURLMatches(
133 cracked_external, 135 cracked_external,
134 GURL(kTestOrigin), 136 GURL(kTestOrigin),
135 kFileSystemTypeExternal, 137 kFileSystemTypeExternal,
136 kFileSystemTypeNativeLocal, 138 kFileSystemTypeNativeLocal,
137 base::FilePath(DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators() , 139 base::FilePath(
140 DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators(),
138 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), 141 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(),
139 "system"); 142 "system");
140 143
141 144
142 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_id); 145 IsolatedContext::GetInstance()->RevokeFileSystem(isolated_id);
143 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); 146 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system");
144 } 147 }
145 #endif // !defiend(OS_CHROMEOS) 148 #endif // !defiend(OS_CHROMEOS)
146 149
147 TEST_F(FileSystemContextTest, FileSystemContextKeepsMountPointsAlive) { 150 TEST_F(FileSystemContextTest, FileSystemContextKeepsMountPointsAlive) {
(...skipping 15 matching lines...) Expand all
163 // FileSystemContext should keep a reference to the |mount_points|, so it 166 // FileSystemContext should keep a reference to the |mount_points|, so it
164 // should be able to resolve the URL. 167 // should be able to resolve the URL.
165 FileSystemURL cracked_external = file_system_context->CrackURL( 168 FileSystemURL cracked_external = file_system_context->CrackURL(
166 CreateRawFileSystemURL("external", "system")); 169 CreateRawFileSystemURL("external", "system"));
167 170
168 ExpectFileSystemURLMatches( 171 ExpectFileSystemURLMatches(
169 cracked_external, 172 cracked_external,
170 GURL(kTestOrigin), 173 GURL(kTestOrigin),
171 kFileSystemTypeExternal, 174 kFileSystemTypeExternal,
172 kFileSystemTypeNativeLocal, 175 kFileSystemTypeNativeLocal,
173 base::FilePath(DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators() , 176 base::FilePath(
177 DRIVE FPL("/test/sys/root/file")).NormalizePathSeparators(),
174 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(), 178 base::FilePath(FPL("system/root/file")).NormalizePathSeparators(),
175 "system"); 179 "system");
176 180
177 // No need to revoke the registered filesystem since |mount_points| lifetime 181 // No need to revoke the registered filesystem since |mount_points| lifetime
178 // is bound to this test. 182 // is bound to this test.
179 } 183 }
180 184
181 TEST_F(FileSystemContextTest, CrackFileSystemURL) { 185 TEST_F(FileSystemContextTest, CrackFileSystemURL) {
182 scoped_refptr<ExternalMountPoints> external_mount_points( 186 scoped_refptr<ExternalMountPoints> external_mount_points(
183 ExternalMountPoints::CreateRefCounted()); 187 ExternalMountPoints::CreateRefCounted());
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
316 base::FilePath(DRIVE FPL("/test/isolated/root"))); 320 base::FilePath(DRIVE FPL("/test/isolated/root")));
317 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system"); 321 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("system");
318 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext"); 322 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem("ext");
319 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem( 323 ExternalMountPoints::GetSystemInstance()->RevokeFileSystem(
320 kIsolatedFileSystemID); 324 kIsolatedFileSystemID);
321 } 325 }
322 326
323 } // namespace 327 } // namespace
324 328
325 } // namespace fileapi 329 } // namespace fileapi
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698