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/files/file_util.h" | 6 #include "base/files/file_util.h" |
7 #include "base/macros.h" | 7 #include "base/macros.h" |
8 #include "base/path_service.h" | 8 #include "base/path_service.h" |
9 #include "base/scoped_observer.h" | 9 #include "base/scoped_observer.h" |
10 #include "base/threading/thread_restrictions.h" | 10 #include "base/threading/thread_restrictions.h" |
11 #include "build/build_config.h" | 11 #include "build/build_config.h" |
12 #include "chrome/browser/apps/app_browsertest_util.h" | 12 #include "chrome/browser/apps/app_browsertest_util.h" |
13 #include "chrome/browser/extensions/api/file_system/file_system_api.h" | 13 #include "chrome/browser/extensions/api/file_system/file_system_api.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/common/chrome_paths.h" | 15 #include "chrome/common/chrome_paths.h" |
| 16 #include "extensions/browser/api/file_system/saved_file_entry.h" |
16 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
17 #include "extensions/browser/extension_registry.h" | 18 #include "extensions/browser/extension_registry.h" |
18 #include "extensions/browser/extension_registry_observer.h" | 19 #include "extensions/browser/extension_registry_observer.h" |
19 | 20 |
20 namespace content { | 21 namespace content { |
21 class BrowserContext; | 22 class BrowserContext; |
22 } | 23 } |
23 | 24 |
24 namespace extensions { | 25 namespace extensions { |
25 | 26 |
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
608 << message_; | 609 << message_; |
609 } | 610 } |
610 | 611 |
611 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRetainEntry) { | 612 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRetainEntry) { |
612 base::FilePath test_file = TempFilePath("writable.txt", true); | 613 base::FilePath test_file = TempFilePath("writable.txt", true); |
613 ASSERT_FALSE(test_file.empty()); | 614 ASSERT_FALSE(test_file.empty()); |
614 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 615 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
615 &test_file); | 616 &test_file); |
616 ASSERT_TRUE(RunPlatformAppTest( | 617 ASSERT_TRUE(RunPlatformAppTest( |
617 "api_test/file_system/retain_entry")) << message_; | 618 "api_test/file_system/retain_entry")) << message_; |
618 std::vector<apps::SavedFileEntry> file_entries = apps::SavedFilesService::Get( | 619 std::vector<SavedFileEntry> file_entries = |
619 profile())->GetAllFileEntries(GetSingleLoadedExtension()->id()); | 620 apps::SavedFilesService::Get(profile())->GetAllFileEntries( |
| 621 GetSingleLoadedExtension()->id()); |
620 ASSERT_EQ(1u, file_entries.size()); | 622 ASSERT_EQ(1u, file_entries.size()); |
621 EXPECT_EQ(test_file, file_entries[0].path); | 623 EXPECT_EQ(test_file, file_entries[0].path); |
622 EXPECT_EQ(1, file_entries[0].sequence_number); | 624 EXPECT_EQ(1, file_entries[0].sequence_number); |
623 EXPECT_FALSE(file_entries[0].is_directory); | 625 EXPECT_FALSE(file_entries[0].is_directory); |
624 } | 626 } |
625 | 627 |
626 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRetainDirectoryEntry) { | 628 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRetainDirectoryEntry) { |
627 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 629 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
628 ASSERT_FALSE(test_file.empty()); | 630 ASSERT_FALSE(test_file.empty()); |
629 base::FilePath test_directory = test_file.DirName(); | 631 base::FilePath test_directory = test_file.DirName(); |
630 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 632 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
631 &test_directory); | 633 &test_directory); |
632 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/retain_directory")) | 634 ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/retain_directory")) |
633 << message_; | 635 << message_; |
634 std::vector<apps::SavedFileEntry> file_entries = apps::SavedFilesService::Get( | 636 std::vector<SavedFileEntry> file_entries = |
635 profile())->GetAllFileEntries(GetSingleLoadedExtension()->id()); | 637 apps::SavedFilesService::Get(profile())->GetAllFileEntries( |
| 638 GetSingleLoadedExtension()->id()); |
636 ASSERT_EQ(1u, file_entries.size()); | 639 ASSERT_EQ(1u, file_entries.size()); |
637 EXPECT_EQ(test_directory, file_entries[0].path); | 640 EXPECT_EQ(test_directory, file_entries[0].path); |
638 EXPECT_EQ(1, file_entries[0].sequence_number); | 641 EXPECT_EQ(1, file_entries[0].sequence_number); |
639 EXPECT_TRUE(file_entries[0].is_directory); | 642 EXPECT_TRUE(file_entries[0].is_directory); |
640 } | 643 } |
641 | 644 |
642 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRestoreEntry) { | 645 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiRestoreEntry) { |
643 base::FilePath test_file = TempFilePath("writable.txt", true); | 646 base::FilePath test_file = TempFilePath("writable.txt", true); |
644 ASSERT_FALSE(test_file.empty()); | 647 ASSERT_FALSE(test_file.empty()); |
645 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 648 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
(...skipping 25 matching lines...) Expand all Loading... |
671 #if !defined(OS_CHROMEOS) | 674 #if !defined(OS_CHROMEOS) |
672 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, RequestFileSystem_NotChromeOS) { | 675 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, RequestFileSystem_NotChromeOS) { |
673 ASSERT_TRUE(RunPlatformAppTestWithFlags( | 676 ASSERT_TRUE(RunPlatformAppTestWithFlags( |
674 "api_test/file_system/request_file_system_not_chromeos", | 677 "api_test/file_system/request_file_system_not_chromeos", |
675 kFlagIgnoreManifestWarnings)) | 678 kFlagIgnoreManifestWarnings)) |
676 << message_; | 679 << message_; |
677 } | 680 } |
678 #endif | 681 #endif |
679 | 682 |
680 } // namespace extensions | 683 } // namespace extensions |
OLD | NEW |