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 "apps/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
6 #include "base/file_util.h" | 6 #include "base/file_util.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "build/build_config.h" | 8 #include "build/build_config.h" |
9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 9 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
10 #include "chrome/browser/extensions/extension_service.h" | 10 #include "chrome/browser/extensions/extension_service.h" |
(...skipping 436 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
447 base::MakeAbsoluteFilePath(TempFilePath("open_existing.txt", true)); | 447 base::MakeAbsoluteFilePath(TempFilePath("open_existing.txt", true)); |
448 ASSERT_FALSE(test_file.empty()); | 448 ASSERT_FALSE(test_file.empty()); |
449 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 449 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
450 chrome::DIR_USER_DATA, test_file.DirName(), false)); | 450 chrome::DIR_USER_DATA, test_file.DirName(), false)); |
451 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 451 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
452 &test_file); | 452 &test_file); |
453 ASSERT_TRUE(RunPlatformAppTest( | 453 ASSERT_TRUE(RunPlatformAppTest( |
454 "api_test/file_system/open_writable_existing_non_writable")) << message_; | 454 "api_test/file_system/open_writable_existing_non_writable")) << message_; |
455 } | 455 } |
456 | 456 |
| 457 #if defined(OS_CHROMEOS) |
| 458 // In Chrome OS the download directory is whitelisted for write. |
| 459 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
| 460 FileSystemApiOpenInDownloadDirForWrite) { |
| 461 base::FilePath test_file = |
| 462 base::MakeAbsoluteFilePath(TempFilePath("writable.txt", true)); |
| 463 ASSERT_FALSE(test_file.empty()); |
| 464 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 465 chrome::DIR_USER_DATA, test_file.DirName(), false)); |
| 466 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
| 467 chrome::DIR_DEFAULT_DOWNLOADS_SAFE, test_file.DirName(), false)); |
| 468 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 469 &test_file); |
| 470 ASSERT_TRUE(RunPlatformAppTest( |
| 471 "api_test/file_system/is_writable_file_entry")) << message_; |
| 472 } |
| 473 #endif |
| 474 |
457 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 475 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
458 FileSystemApiOpenInChromeDirForWrite) { | 476 FileSystemApiOpenInChromeDirForWrite) { |
459 base::FilePath test_file = | 477 base::FilePath test_file = |
460 base::MakeAbsoluteFilePath(TempFilePath("open_existing.txt", true)); | 478 base::MakeAbsoluteFilePath(TempFilePath("open_existing.txt", true)); |
461 ASSERT_FALSE(test_file.empty()); | 479 ASSERT_FALSE(test_file.empty()); |
462 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( | 480 ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded( |
463 chrome::DIR_APP, test_file.DirName(), false)); | 481 chrome::DIR_APP, test_file.DirName(), false)); |
464 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 482 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
465 &test_file); | 483 &test_file); |
466 ASSERT_TRUE(RunPlatformAppTest( | 484 ASSERT_TRUE(RunPlatformAppTest( |
467 "api_test/file_system/open_writable_existing_non_writable")) << message_; | 485 "api_test/file_system/open_writable_existing_non_writable")) << message_; |
468 } | 486 } |
469 | 487 |
470 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 488 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
471 FileSystemApiOpenInAppDirectoryForWrite) { | 489 FileSystemApiOpenInAppDirectoryForWrite) { |
472 FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest(); | 490 FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest(); |
473 { | 491 { |
474 AppInstallObserver observer( | 492 AppInstallObserver observer( |
475 base::Bind(SetLastChooseEntryDirectoryToAppDirectory, | 493 base::Bind(SetLastChooseEntryDirectoryToAppDirectory, |
476 extensions::ExtensionSystem::Get( | 494 extensions::ExtensionSystem::Get( |
477 profile())->extension_service()->extension_prefs())); | 495 profile())->extension_service()->extension_prefs())); |
478 ASSERT_TRUE(RunPlatformAppTest( | 496 ASSERT_TRUE(RunPlatformAppTest( |
479 "api_test/file_system/open_writable_existing_non_writable")) | 497 "api_test/file_system/open_writable_existing_non_writable")) |
480 << message_; | 498 << message_; |
481 } | 499 } |
482 } | 500 } |
OLD | NEW |