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

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

Issue 6864040: Fixed file/directory url resolution for external mount point provider. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_path_manager.h" 5 #include "webkit/fileapi/file_system_path_manager.h"
6 6
7 #include <set> 7 #include <set>
8 #include <string> 8 #include <string>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
13 #include "base/memory/scoped_callback_factory.h" 13 #include "base/memory/scoped_callback_factory.h"
14 #include "base/memory/scoped_ptr.h" 14 #include "base/memory/scoped_ptr.h"
15 #include "base/memory/scoped_temp_dir.h" 15 #include "base/memory/scoped_temp_dir.h"
16 #include "base/message_loop.h" 16 #include "base/message_loop.h"
17 #include "base/message_loop_proxy.h" 17 #include "base/message_loop_proxy.h"
18 #include "base/sys_string_conversions.h"
19 #include "base/utf_string_conversions.h"
18 #include "googleurl/src/gurl.h" 20 #include "googleurl/src/gurl.h"
19 #include "testing/gtest/include/gtest/gtest.h" 21 #include "testing/gtest/include/gtest/gtest.h"
20 #include "webkit/fileapi/file_system_util.h" 22 #include "webkit/fileapi/file_system_util.h"
21 #include "webkit/fileapi/sandbox_mount_point_provider.h" 23 #include "webkit/fileapi/sandbox_mount_point_provider.h"
22 #include "webkit/quota/special_storage_policy.h" 24 #include "webkit/quota/special_storage_policy.h"
23 25
24 using namespace fileapi; 26 using namespace fileapi;
25 27
26 namespace { 28 namespace {
27 29
(...skipping 24 matching lines...) Expand all
52 { fileapi::kFileSystemTypePersistent, "http://bar.com/", 54 { fileapi::kFileSystemTypePersistent, "http://bar.com/",
53 "http_bar.com_0" PS "Persistent" }, 55 "http_bar.com_0" PS "Persistent" },
54 { fileapi::kFileSystemTypeTemporary, "https://foo:2/", 56 { fileapi::kFileSystemTypeTemporary, "https://foo:2/",
55 "https_foo_2" PS "Temporary" }, 57 "https_foo_2" PS "Temporary" },
56 { fileapi::kFileSystemTypePersistent, "https://foo:2/", 58 { fileapi::kFileSystemTypePersistent, "https://foo:2/",
57 "https_foo_2" PS "Persistent" }, 59 "https_foo_2" PS "Persistent" },
58 { fileapi::kFileSystemTypeTemporary, "https://bar.com/", 60 { fileapi::kFileSystemTypeTemporary, "https://bar.com/",
59 "https_bar.com_0" PS "Temporary" }, 61 "https_bar.com_0" PS "Temporary" },
60 { fileapi::kFileSystemTypePersistent, "https://bar.com/", 62 { fileapi::kFileSystemTypePersistent, "https://bar.com/",
61 "https_bar.com_0" PS "Persistent" }, 63 "https_bar.com_0" PS "Persistent" },
64 #if defined(OS_CHROMEOS)
65 { fileapi::kFileSystemTypeExternal, "chrome-extension://foo/",
66 "chrome-extension__0" PS "External" },
67 #endif
62 }; 68 };
63 69
64 const struct RootPathFileURITest { 70 const struct RootPathFileURITest {
65 fileapi::FileSystemType type; 71 fileapi::FileSystemType type;
66 const char* origin_url; 72 const char* origin_url;
67 const char* expected_path; 73 const char* expected_path;
74 const char* virtual_path;
68 } kRootPathFileURITestCases[] = { 75 } kRootPathFileURITestCases[] = {
69 { fileapi::kFileSystemTypeTemporary, "file:///", 76 { fileapi::kFileSystemTypeTemporary, "file:///",
70 "file__0" PS "Temporary" }, 77 "file__0" PS "Temporary", NULL },
71 { fileapi::kFileSystemTypePersistent, "file:///", 78 { fileapi::kFileSystemTypePersistent, "file:///",
72 "file__0" PS "Persistent" }, 79 "file__0" PS "Persistent", NULL },
73 // TODO(zelidrag): Add fileapi::kFileSystemTypeLocal test cases here once 80 #if defined(OS_CHROMEOS)
74 // we fix ChromeOS build of this test. 81 { fileapi::kFileSystemTypeExternal, "chrome-extension://foo/",
82 "chrome-extension__0" PS "External", "testing/test_file.txt" },
ericu 2011/04/19 20:30:49 We don't need to stick on a file name here and pul
zel 2011/04/19 23:14:00 Done.
83 #endif
75 }; 84 };
76 85
77 const struct CheckValidPathTest { 86 const struct CheckValidPathTest {
78 FilePath::StringType path; 87 FilePath::StringType path;
79 bool expected_valid; 88 bool expected_valid;
80 } kCheckValidPathTestCases[] = { 89 } kCheckValidPathTestCases[] = {
81 { FILE_PATH_LITERAL("//tmp/foo.txt"), false, }, 90 { FILE_PATH_LITERAL("//tmp/foo.txt"), false, },
82 { FILE_PATH_LITERAL("//etc/hosts"), false, }, 91 { FILE_PATH_LITERAL("//etc/hosts"), false, },
83 { FILE_PATH_LITERAL("foo.txt"), true, }, 92 { FILE_PATH_LITERAL("foo.txt"), true, },
84 { FILE_PATH_LITERAL("a/b/c"), true, }, 93 { FILE_PATH_LITERAL("a/b/c"), true, },
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 { FILE_PATH_LITERAL("ab|.txt"), true, }, 165 { FILE_PATH_LITERAL("ab|.txt"), true, },
157 { FILE_PATH_LITERAL("\\ab"), true, }, 166 { FILE_PATH_LITERAL("\\ab"), true, },
158 { FILE_PATH_LITERAL("/ab"), true, }, 167 { FILE_PATH_LITERAL("/ab"), true, },
159 { FILE_PATH_LITERAL("<ab"), true, }, 168 { FILE_PATH_LITERAL("<ab"), true, },
160 { FILE_PATH_LITERAL(">ab"), true, }, 169 { FILE_PATH_LITERAL(">ab"), true, },
161 { FILE_PATH_LITERAL(":ab"), true, }, 170 { FILE_PATH_LITERAL(":ab"), true, },
162 { FILE_PATH_LITERAL("?ab"), true, }, 171 { FILE_PATH_LITERAL("?ab"), true, },
163 { FILE_PATH_LITERAL("|ab"), true, }, 172 { FILE_PATH_LITERAL("|ab"), true, },
164 }; 173 };
165 174
175 FilePath UTF8ToFilePath(const std::string& str) {
176 FilePath::StringType result;
177 #if defined(OS_POSIX)
178 result = base::SysWideToNativeMB(UTF8ToWide(str));
179 #elif defined(OS_WIN)
180 result = UTF8ToUTF16(str);
181 #endif
182 return FilePath(result);
183 }
184
166 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy { 185 class TestSpecialStoragePolicy : public quota::SpecialStoragePolicy {
167 public: 186 public:
168 virtual bool IsStorageProtected(const GURL& origin) { 187 virtual bool IsStorageProtected(const GURL& origin) {
169 return false; 188 return false;
170 } 189 }
171 190
172 virtual bool IsStorageUnlimited(const GURL& origin) { 191 virtual bool IsStorageUnlimited(const GURL& origin) {
173 return true; 192 return true;
174 } 193 }
175 194
(...skipping 14 matching lines...) Expand all
190 ASSERT_TRUE(data_dir_.CreateUniqueTempDir()); 209 ASSERT_TRUE(data_dir_.CreateUniqueTempDir());
191 root_path_callback_status_ = false; 210 root_path_callback_status_ = false;
192 root_path_.clear(); 211 root_path_.clear();
193 file_system_name_.clear(); 212 file_system_name_.clear();
194 } 213 }
195 214
196 protected: 215 protected:
197 FileSystemPathManager* NewPathManager( 216 FileSystemPathManager* NewPathManager(
198 bool incognito, 217 bool incognito,
199 bool allow_file_access) { 218 bool allow_file_access) {
200 return new FileSystemPathManager( 219 FileSystemPathManager* manager = new FileSystemPathManager(
201 base::MessageLoopProxy::CreateForCurrentThread(), 220 base::MessageLoopProxy::CreateForCurrentThread(),
202 data_dir_.path(), 221 data_dir_.path(),
203 scoped_refptr<quota::SpecialStoragePolicy>( 222 scoped_refptr<quota::SpecialStoragePolicy>(
204 new TestSpecialStoragePolicy()), 223 new TestSpecialStoragePolicy()),
205 incognito, 224 incognito,
206 allow_file_access); 225 allow_file_access);
226 #if defined(OS_CHROMEOS)
227 fileapi::ExternalFileSystemMountPointProvider* ext_provider =
228 manager->external_provider();
229 ext_provider->AddMountPoint(FilePath("/tmp/testing"));
230 #endif
231 return manager;
207 } 232 }
208 233
209 void OnGetRootPath(bool success, 234 void OnGetRootPath(bool success,
210 const FilePath& root_path, 235 const FilePath& root_path,
211 const std::string& name) { 236 const std::string& name) {
212 root_path_callback_status_ = success; 237 root_path_callback_status_ = success;
213 root_path_ = root_path; 238 root_path_ = root_path;
214 file_system_name_ = name; 239 file_system_name_ = name;
215 } 240 }
216 241
217 bool GetRootPath(FileSystemPathManager* manager, 242 bool GetRootPath(FileSystemPathManager* manager,
218 const GURL& origin_url, 243 const GURL& origin_url,
219 fileapi::FileSystemType type, 244 fileapi::FileSystemType type,
220 bool create, 245 bool create,
246 bool is_file_system,
247 const FilePath& virtual_path,
ericu 2011/04/19 20:30:49 Obsolete params.
zel 2011/04/19 23:14:00 Done.
221 FilePath* root_path) { 248 FilePath* root_path) {
222 manager->GetFileSystemRootPath(origin_url, type, create, 249 manager->GetFileSystemRootPath(origin_url, type, create,
223 callback_factory_.NewCallback( 250 callback_factory_.NewCallback(
224 &FileSystemPathManagerTest::OnGetRootPath)); 251 &FileSystemPathManagerTest::OnGetRootPath));
225 MessageLoop::current()->RunAllPending(); 252 MessageLoop::current()->RunAllPending();
226 if (root_path) 253 if (root_path)
227 *root_path = root_path_; 254 *root_path = root_path_;
228 return root_path_callback_status_; 255 return root_path_callback_status_;
229 } 256 }
230 257
231 FilePath data_path() { return data_dir_.path(); } 258 FilePath data_path() { return data_dir_.path(); }
232 FilePath file_system_path() { 259 FilePath file_system_path() {
233 return data_dir_.path().Append( 260 return data_dir_.path().Append(
234 SandboxMountPointProvider::kFileSystemDirectory); 261 SandboxMountPointProvider::kFileSystemDirectory);
235 } 262 }
263 FilePath external_file_system_path() {
264 return UTF8ToFilePath(std::string(fileapi::kExternalDir));
265 }
266 FilePath external_file_path_root() {
267 return UTF8ToFilePath(std::string("/tmp"));
268 }
236 269
237 private: 270 private:
238 ScopedTempDir data_dir_; 271 ScopedTempDir data_dir_;
239 base::ScopedCallbackFactory<FileSystemPathManagerTest> callback_factory_; 272 base::ScopedCallbackFactory<FileSystemPathManagerTest> callback_factory_;
240 273
241 bool root_path_callback_status_; 274 bool root_path_callback_status_;
242 FilePath root_path_; 275 FilePath root_path_;
243 std::string file_system_name_; 276 std::string file_system_name_;
244 277
245 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManagerTest); 278 DISALLOW_COPY_AND_ASSIGN(FileSystemPathManagerTest);
246 }; 279 };
247 280
248 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) { 281 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamine) {
249 std::vector<FilePath> returned_root_path( 282 std::vector<FilePath> returned_root_path(
250 ARRAYSIZE_UNSAFE(kRootPathTestCases)); 283 ARRAYSIZE_UNSAFE(kRootPathTestCases));
251 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); 284 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false));
252 285
253 // Create a new root directory. 286 // Create a new root directory.
254 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 287 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
255 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " " 288 SCOPED_TRACE(testing::Message() << "RootPath (create) #" << i << " "
256 << kRootPathTestCases[i].expected_path); 289 << kRootPathTestCases[i].expected_path);
257 290
258 FilePath root_path; 291 FilePath root_path;
259 EXPECT_TRUE(GetRootPath(manager.get(), 292 EXPECT_TRUE(GetRootPath(manager.get(),
260 GURL(kRootPathTestCases[i].origin_url), 293 GURL(kRootPathTestCases[i].origin_url),
261 kRootPathTestCases[i].type, 294 kRootPathTestCases[i].type,
262 true /* create */, &root_path)); 295 true /* create */, true /* is_file_system */,
296 FilePath(),
297 &root_path));
263 298
264 FilePath expected = file_system_path().AppendASCII( 299 if (kRootPathTestCases[i].type != fileapi::kFileSystemTypeExternal) {
265 kRootPathTestCases[i].expected_path); 300 FilePath expected = file_system_path().AppendASCII(
266 EXPECT_EQ(expected.value(), root_path.DirName().value()); 301 kRootPathTestCases[i].expected_path);
267 EXPECT_TRUE(file_util::DirectoryExists(root_path)); 302 EXPECT_EQ(expected.value(), root_path.DirName().value());
303 EXPECT_TRUE(file_util::DirectoryExists(root_path));
304 } else {
305 // External file system root path is virtual one and does not match
306 // anything from the actual file system.
307 EXPECT_EQ(external_file_system_path().value(),
308 root_path.value());
309 }
268 ASSERT_TRUE(returned_root_path.size() > i); 310 ASSERT_TRUE(returned_root_path.size() > i);
269 returned_root_path[i] = root_path; 311 returned_root_path[i] = root_path;
270 } 312 }
271 313
272 // Get the root directory with create=false and see if we get the 314 // Get the root directory with create=false and see if we get the
273 // same directory. 315 // same directory.
274 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 316 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
275 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " " 317 SCOPED_TRACE(testing::Message() << "RootPath (get) #" << i << " "
276 << kRootPathTestCases[i].expected_path); 318 << kRootPathTestCases[i].expected_path);
277 319
278 FilePath root_path; 320 FilePath root_path;
279 EXPECT_TRUE(GetRootPath(manager.get(), 321 EXPECT_TRUE(GetRootPath(manager.get(),
280 GURL(kRootPathTestCases[i].origin_url), 322 GURL(kRootPathTestCases[i].origin_url),
281 kRootPathTestCases[i].type, 323 kRootPathTestCases[i].type,
282 false /* create */, &root_path)); 324 false /* create */, true /* is_file_system */,
325 FilePath(), &root_path));
283 ASSERT_TRUE(returned_root_path.size() > i); 326 ASSERT_TRUE(returned_root_path.size() > i);
284 EXPECT_EQ(returned_root_path[i].value(), root_path.value()); 327 EXPECT_EQ(returned_root_path[i].value(), root_path.value());
285 } 328 }
286 } 329 }
287 330
288 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamineWithNewManager) { 331 TEST_F(FileSystemPathManagerTest, GetRootPathCreateAndExamineWithNewManager) {
289 std::vector<FilePath> returned_root_path( 332 std::vector<FilePath> returned_root_path(
290 ARRAYSIZE_UNSAFE(kRootPathTestCases)); 333 ARRAYSIZE_UNSAFE(kRootPathTestCases));
291 scoped_ptr<FileSystemPathManager> manager1(NewPathManager(false, false)); 334 scoped_ptr<FileSystemPathManager> manager1(NewPathManager(false, false));
292 scoped_ptr<FileSystemPathManager> manager2(NewPathManager(false, false)); 335 scoped_ptr<FileSystemPathManager> manager2(NewPathManager(false, false));
293 336
294 GURL origin_url("http://foo.com:1/"); 337 GURL origin_url("http://foo.com:1/");
295 338
296 FilePath root_path1; 339 FilePath root_path1;
297 EXPECT_TRUE(GetRootPath(manager1.get(), origin_url, 340 EXPECT_TRUE(GetRootPath(manager1.get(), origin_url,
298 kFileSystemTypeTemporary, true, &root_path1)); 341 kFileSystemTypeTemporary, true, false, FilePath(),
342 &root_path1));
299 FilePath root_path2; 343 FilePath root_path2;
300 EXPECT_TRUE(GetRootPath(manager2.get(), origin_url, 344 EXPECT_TRUE(GetRootPath(manager2.get(), origin_url,
301 kFileSystemTypeTemporary, false, &root_path2)); 345 kFileSystemTypeTemporary, false, false, FilePath(),
346 &root_path2));
302 347
303 EXPECT_EQ(root_path1.value(), root_path2.value()); 348 EXPECT_EQ(root_path1.value(), root_path2.value());
304 } 349 }
305 350
306 TEST_F(FileSystemPathManagerTest, GetRootPathGetWithoutCreate) { 351 TEST_F(FileSystemPathManagerTest, GetRootPathGetWithoutCreate) {
307 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); 352 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false));
308 353
309 // Try to get a root directory without creating. 354 // Try to get a root directory without creating.
310 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 355 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
311 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " 356 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " "
312 << kRootPathTestCases[i].expected_path); 357 << kRootPathTestCases[i].expected_path);
313 EXPECT_FALSE(GetRootPath(manager.get(), 358 EXPECT_FALSE(GetRootPath(manager.get(),
314 GURL(kRootPathTestCases[i].origin_url), 359 GURL(kRootPathTestCases[i].origin_url),
315 kRootPathTestCases[i].type, 360 kRootPathTestCases[i].type,
316 false /* create */, NULL)); 361 false /* create */, false /* is_file_system */,
362 FilePath(), NULL));
317 } 363 }
318 } 364 }
319 365
320 TEST_F(FileSystemPathManagerTest, GetRootPathInIncognito) { 366 TEST_F(FileSystemPathManagerTest, GetRootPathInIncognito) {
321 scoped_ptr<FileSystemPathManager> manager(NewPathManager( 367 scoped_ptr<FileSystemPathManager> manager(NewPathManager(
322 true /* incognito */, false)); 368 true /* incognito */, false));
323 369
324 // Try to get a root directory. 370 // Try to get a root directory.
325 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { 371 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) {
326 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " 372 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " "
327 << kRootPathTestCases[i].expected_path); 373 << kRootPathTestCases[i].expected_path);
328 EXPECT_FALSE(GetRootPath(manager.get(), 374 EXPECT_FALSE(GetRootPath(manager.get(),
329 GURL(kRootPathTestCases[i].origin_url), 375 GURL(kRootPathTestCases[i].origin_url),
330 kRootPathTestCases[i].type, 376 kRootPathTestCases[i].type,
331 true /* create */, NULL)); 377 true /* create */, false /* is_file_system */,
378 FilePath(), NULL));
332 } 379 }
333 } 380 }
334 381
335 TEST_F(FileSystemPathManagerTest, GetRootPathFileURI) { 382 TEST_F(FileSystemPathManagerTest, GetRootPathFileURI) {
336 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); 383 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false));
337 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { 384 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) {
338 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" 385 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #"
339 << i << " " << kRootPathFileURITestCases[i].expected_path); 386 << i << " " << kRootPathFileURITestCases[i].expected_path);
340 EXPECT_FALSE(GetRootPath(manager.get(), 387 EXPECT_FALSE(GetRootPath(manager.get(),
341 GURL(kRootPathFileURITestCases[i].origin_url), 388 GURL(kRootPathFileURITestCases[i].origin_url),
342 kRootPathFileURITestCases[i].type, 389 kRootPathFileURITestCases[i].type,
343 true /* create */, NULL)); 390 true /* create */, false /* is_file_system */,
391 FilePath(), NULL));
344 } 392 }
345 } 393 }
346 394
347 TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) { 395 TEST_F(FileSystemPathManagerTest, GetRootPathFileURIWithAllowFlag) {
348 scoped_ptr<FileSystemPathManager> manager(NewPathManager( 396 scoped_ptr<FileSystemPathManager> manager(NewPathManager(
349 false, true /* allow_file_access_from_files */)); 397 false, true /* allow_file_access_from_files */));
350 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { 398 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) {
351 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" 399 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #"
352 << i << " " << kRootPathFileURITestCases[i].expected_path); 400 << i << " " << kRootPathFileURITestCases[i].expected_path);
353 FilePath root_path; 401 FilePath root_path;
354 EXPECT_TRUE(GetRootPath(manager.get(), 402 EXPECT_TRUE(GetRootPath(manager.get(),
355 GURL(kRootPathFileURITestCases[i].origin_url), 403 GURL(kRootPathFileURITestCases[i].origin_url),
356 kRootPathFileURITestCases[i].type, 404 kRootPathFileURITestCases[i].type,
357 true /* create */, &root_path)); 405 true /* create */, false /* is_file_system */,
358 FilePath expected = file_system_path().AppendASCII( 406 (kRootPathFileURITestCases[i].virtual_path ?
359 kRootPathFileURITestCases[i].expected_path); 407 UTF8ToFilePath(std::string(
360 EXPECT_EQ(expected.value(), root_path.DirName().value()); 408 kRootPathFileURITestCases[i].virtual_path)) :
361 EXPECT_TRUE(file_util::DirectoryExists(root_path)); 409 FilePath()),
410 &root_path));
411 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) {
412 FilePath expected = file_system_path().AppendASCII(
413 kRootPathFileURITestCases[i].expected_path);
414 EXPECT_EQ(expected.value(), root_path.DirName().value());
415 EXPECT_TRUE(file_util::DirectoryExists(root_path));
416 } else {
417 EXPECT_EQ(external_file_path_root().value(), root_path.value());
418 }
362 } 419 }
363 } 420 }
364 421
365 TEST_F(FileSystemPathManagerTest, IsRestrictedName) { 422 TEST_F(FileSystemPathManagerTest, IsRestrictedName) {
366 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false)); 423 scoped_ptr<FileSystemPathManager> manager(NewPathManager(false, false));
367 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { 424 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) {
368 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " 425 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " "
369 << kIsRestrictedNameTestCases[i].name); 426 << kIsRestrictedNameTestCases[i].name);
370 FilePath name(kIsRestrictedNameTestCases[i].name); 427 FilePath name(kIsRestrictedNameTestCases[i].name);
371 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, 428 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous,
372 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name)); 429 manager->IsRestrictedFileName(kFileSystemTypeTemporary, name));
373 } 430 }
374 } 431 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698