| 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_prefs.h" | 10 #include "chrome/browser/extensions/extension_prefs.h" |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 85 if (!temp_dir_.CreateUniqueTempDir()) { | 85 if (!temp_dir_.CreateUniqueTempDir()) { |
| 86 ADD_FAILURE() << "CreateUniqueTempDir failed"; | 86 ADD_FAILURE() << "CreateUniqueTempDir failed"; |
| 87 return base::FilePath(); | 87 return base::FilePath(); |
| 88 } | 88 } |
| 89 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( | 89 FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest( |
| 90 "test_temp", temp_dir_.path()); | 90 "test_temp", temp_dir_.path()); |
| 91 | 91 |
| 92 base::FilePath destination = temp_dir_.path().AppendASCII(destination_name); | 92 base::FilePath destination = temp_dir_.path().AppendASCII(destination_name); |
| 93 if (copy_gold) { | 93 if (copy_gold) { |
| 94 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 94 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
| 95 EXPECT_TRUE(file_util::CopyFile(source, destination)); | 95 EXPECT_TRUE(base::CopyFile(source, destination)); |
| 96 } | 96 } |
| 97 return destination; | 97 return destination; |
| 98 } | 98 } |
| 99 | 99 |
| 100 void CheckStoredDirectoryMatches(const base::FilePath& filename) { | 100 void CheckStoredDirectoryMatches(const base::FilePath& filename) { |
| 101 const Extension* extension = GetSingleLoadedExtension(); | 101 const Extension* extension = GetSingleLoadedExtension(); |
| 102 ASSERT_TRUE(extension); | 102 ASSERT_TRUE(extension); |
| 103 std::string extension_id = extension->id(); | 103 std::string extension_id = extension->id(); |
| 104 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); | 104 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); |
| 105 base::FilePath stored_value; | 105 base::FilePath stored_value; |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 146 | 146 |
| 147 #if defined(OS_MACOSX) | 147 #if defined(OS_MACOSX) |
| 148 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, | 148 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, |
| 149 FileSystemApiGetDisplayPathPrettifyMac) { | 149 FileSystemApiGetDisplayPathPrettifyMac) { |
| 150 // On Mac, "test.localized" will be localized into just "test". | 150 // On Mac, "test.localized" will be localized into just "test". |
| 151 base::FilePath test_path = TempFilePath("test.localized", false); | 151 base::FilePath test_path = TempFilePath("test.localized", false); |
| 152 ASSERT_TRUE(file_util::CreateDirectory(test_path)); | 152 ASSERT_TRUE(file_util::CreateDirectory(test_path)); |
| 153 | 153 |
| 154 base::FilePath test_file = test_path.AppendASCII("gold.txt"); | 154 base::FilePath test_file = test_path.AppendASCII("gold.txt"); |
| 155 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); | 155 base::FilePath source = test_root_folder_.AppendASCII("gold.txt"); |
| 156 EXPECT_TRUE(file_util::CopyFile(source, test_file)); | 156 EXPECT_TRUE(base::CopyFile(source, test_file)); |
| 157 | 157 |
| 158 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( | 158 FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest( |
| 159 &test_file); | 159 &test_file); |
| 160 ASSERT_TRUE(RunPlatformAppTest( | 160 ASSERT_TRUE(RunPlatformAppTest( |
| 161 "api_test/file_system/get_display_path_prettify_mac")) << message_; | 161 "api_test/file_system/get_display_path_prettify_mac")) << message_; |
| 162 } | 162 } |
| 163 #endif | 163 #endif |
| 164 | 164 |
| 165 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenExistingFileTest) { | 165 IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenExistingFileTest) { |
| 166 base::FilePath test_file = TempFilePath("open_existing.txt", true); | 166 base::FilePath test_file = TempFilePath("open_existing.txt", true); |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 497 AppInstallObserver observer( | 497 AppInstallObserver observer( |
| 498 base::Bind(SetLastChooseEntryDirectoryToAppDirectory, | 498 base::Bind(SetLastChooseEntryDirectoryToAppDirectory, |
| 499 ExtensionPrefs::Get(profile()))); | 499 ExtensionPrefs::Get(profile()))); |
| 500 ASSERT_TRUE(RunPlatformAppTest( | 500 ASSERT_TRUE(RunPlatformAppTest( |
| 501 "api_test/file_system/open_writable_existing_non_writable")) | 501 "api_test/file_system/open_writable_existing_non_writable")) |
| 502 << message_; | 502 << message_; |
| 503 } | 503 } |
| 504 } | 504 } |
| 505 | 505 |
| 506 } // namespace extensions | 506 } // namespace extensions |
| OLD | NEW |