| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 <set> | 5 #include <set> |
| 6 #include <string> | 6 #include <string> |
| 7 | 7 |
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 354 kFileSystemTypeTemporary, true, &root_path1)); | 354 kFileSystemTypeTemporary, true, &root_path1)); |
| 355 | 355 |
| 356 SetupNewContext(CreateDisallowFileAccessOptions()); | 356 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 357 FilePath root_path2; | 357 FilePath root_path2; |
| 358 EXPECT_TRUE(GetRootPath(origin_url, | 358 EXPECT_TRUE(GetRootPath(origin_url, |
| 359 kFileSystemTypeTemporary, false, &root_path2)); | 359 kFileSystemTypeTemporary, false, &root_path2)); |
| 360 | 360 |
| 361 EXPECT_EQ(root_path1.value(), root_path2.value()); | 361 EXPECT_EQ(root_path1.value(), root_path2.value()); |
| 362 } | 362 } |
| 363 | 363 |
| 364 TEST_F(FileSystemMountPointProviderTest, GetRootPathGetWithoutCreate) { | 364 // http://crbug.com/109342 |
| 365 #if defined(OS_CHROMEOS) |
| 366 #define MAYBE_GetRootPathGetWithoutCreate FAILS_GetRootPathGetWithoutCreate |
| 367 #else |
| 368 #define MAYBE_GetRootPathGetWithoutCreate GetRootPathGetWithoutCreate |
| 369 #endif |
| 370 TEST_F(FileSystemMountPointProviderTest, MAYBE_GetRootPathGetWithoutCreate) { |
| 365 SetupNewContext(CreateDisallowFileAccessOptions()); | 371 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 366 | 372 |
| 367 // Try to get a root directory without creating. | 373 // Try to get a root directory without creating. |
| 368 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 374 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 369 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " | 375 SCOPED_TRACE(testing::Message() << "RootPath (create=false) #" << i << " " |
| 370 << kRootPathTestCases[i].expected_path); | 376 << kRootPathTestCases[i].expected_path); |
| 371 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), | 377 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 372 kRootPathTestCases[i].type, | 378 kRootPathTestCases[i].type, |
| 373 false /* create */, NULL)); | 379 false /* create */, NULL)); |
| 374 } | 380 } |
| 375 } | 381 } |
| 376 | 382 |
| 377 TEST_F(FileSystemMountPointProviderTest, GetRootPathInIncognito) { | 383 // http://crbug.com/109342 |
| 384 #if defined(OS_CHROMEOS) |
| 385 #define MAYBE_GetRootPathInIncognito FAILS_GetRootPathInIncognito |
| 386 #else |
| 387 #define MAYBE_GetRootPathInIncognito GetRootPathInIncognito |
| 388 #endif |
| 389 TEST_F(FileSystemMountPointProviderTest, MAYBE_GetRootPathInIncognito) { |
| 378 SetupNewContext(CreateIncognitoFileSystemOptions()); | 390 SetupNewContext(CreateIncognitoFileSystemOptions()); |
| 379 | 391 |
| 380 // Try to get a root directory. | 392 // Try to get a root directory. |
| 381 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { | 393 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathTestCases); ++i) { |
| 382 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " | 394 SCOPED_TRACE(testing::Message() << "RootPath (incognito) #" << i << " " |
| 383 << kRootPathTestCases[i].expected_path); | 395 << kRootPathTestCases[i].expected_path); |
| 384 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), | 396 EXPECT_FALSE(GetRootPath(GURL(kRootPathTestCases[i].origin_url), |
| 385 kRootPathTestCases[i].type, | 397 kRootPathTestCases[i].type, |
| 386 true /* create */, NULL)); | 398 true /* create */, NULL)); |
| 387 } | 399 } |
| 388 } | 400 } |
| 389 | 401 |
| 390 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURI) { | 402 // http://crbug.com/109342 |
| 403 #if defined(OS_CHROMEOS) |
| 404 #define MAYBE_GetRootPathFileURI FAILS_GetRootPathFileURI |
| 405 #else |
| 406 #define MAYBE_GetRootPathFileURI GetRootPathFileURI |
| 407 #endif |
| 408 TEST_F(FileSystemMountPointProviderTest, MAYBE_GetRootPathFileURI) { |
| 391 SetupNewContext(CreateDisallowFileAccessOptions()); | 409 SetupNewContext(CreateDisallowFileAccessOptions()); |
| 392 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 410 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
| 393 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" | 411 SCOPED_TRACE(testing::Message() << "RootPathFileURI (disallow) #" |
| 394 << i << " " << kRootPathFileURITestCases[i].expected_path); | 412 << i << " " << kRootPathFileURITestCases[i].expected_path); |
| 395 EXPECT_FALSE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), | 413 EXPECT_FALSE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
| 396 kRootPathFileURITestCases[i].type, | 414 kRootPathFileURITestCases[i].type, |
| 397 true /* create */, NULL)); | 415 true /* create */, NULL)); |
| 398 } | 416 } |
| 399 } | 417 } |
| 400 | 418 |
| 401 TEST_F(FileSystemMountPointProviderTest, GetRootPathFileURIWithAllowFlag) { | 419 // http://crbug.com/109342 |
| 420 #if defined(OS_CHROMEOS) |
| 421 #define MAYBE_GetRootPathFileURIWithAllowFlag \ |
| 422 FAILS_GetRootPathFileURIWithAllowFlag |
| 423 #else |
| 424 #define MAYBE_GetRootPathFileURIWithAllowFlag GetRootPathFileURIWithAllowFlag |
| 425 #endif |
| 426 TEST_F(FileSystemMountPointProviderTest, |
| 427 MAYBE_GetRootPathFileURIWithAllowFlag) { |
| 402 SetupNewContext(CreateRootPathTestOptions()); | 428 SetupNewContext(CreateRootPathTestOptions()); |
| 403 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { | 429 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kRootPathFileURITestCases); ++i) { |
| 404 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" | 430 SCOPED_TRACE(testing::Message() << "RootPathFileURI (allow) #" |
| 405 << i << " " << kRootPathFileURITestCases[i].expected_path); | 431 << i << " " << kRootPathFileURITestCases[i].expected_path); |
| 406 FilePath root_path; | 432 FilePath root_path; |
| 407 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), | 433 EXPECT_TRUE(GetRootPath(GURL(kRootPathFileURITestCases[i].origin_url), |
| 408 kRootPathFileURITestCases[i].type, | 434 kRootPathFileURITestCases[i].type, |
| 409 true /* create */, &root_path)); | 435 true /* create */, &root_path)); |
| 410 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { | 436 if (kRootPathFileURITestCases[i].type != fileapi::kFileSystemTypeExternal) { |
| 411 FilePath expected = file_system_path().AppendASCII( | 437 FilePath expected = file_system_path().AppendASCII( |
| (...skipping 11 matching lines...) Expand all Loading... |
| 423 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { | 449 for (size_t i = 0; i < ARRAYSIZE_UNSAFE(kIsRestrictedNameTestCases); ++i) { |
| 424 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " | 450 SCOPED_TRACE(testing::Message() << "IsRestrictedName #" << i << " " |
| 425 << kIsRestrictedNameTestCases[i].name); | 451 << kIsRestrictedNameTestCases[i].name); |
| 426 FilePath name(kIsRestrictedNameTestCases[i].name); | 452 FilePath name(kIsRestrictedNameTestCases[i].name); |
| 427 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, | 453 EXPECT_EQ(kIsRestrictedNameTestCases[i].expected_dangerous, |
| 428 provider(kFileSystemTypeTemporary)->IsRestrictedFileName(name)); | 454 provider(kFileSystemTypeTemporary)->IsRestrictedFileName(name)); |
| 429 } | 455 } |
| 430 } | 456 } |
| 431 | 457 |
| 432 } // namespace fileapi | 458 } // namespace fileapi |
| OLD | NEW |