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

Unified Diff: chrome/browser/extensions/api/file_system/file_system_apitest.cc

Issue 18331017: Support choosing multiple files with fileSystem.chooseEntry. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 7 years, 5 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/api/file_system/file_system_apitest.cc
diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest.cc b/chrome/browser/extensions/api/file_system/file_system_apitest.cc
index a08faadc671aad71d04088d766e169f4de1d33b9..9f1c709626bd7122494f5e6a2738d74fc26fb382 100644
--- a/chrome/browser/extensions/api/file_system/file_system_apitest.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_apitest.cc
@@ -97,6 +97,30 @@ class FileSystemApiTest : public PlatformAppBrowserTest {
return destination;
}
+ std::vector<base::FilePath> TempFilePaths(
+ const std::vector<std::string>& destination_names,
+ bool copy_gold) {
+ if (!temp_dir_.CreateUniqueTempDir()) {
+ ADD_FAILURE() << "CreateUniqueTempDir failed";
+ return std::vector<base::FilePath>();
+ }
+ FileSystemChooseEntryFunction::RegisterTempExternalFileSystemForTest(
+ "test_temp", temp_dir_.path());
+
+ std::vector<base::FilePath> result;
+ for (std::vector<std::string>::const_iterator it =
+ destination_names.begin();
+ it != destination_names.end(); ++it) {
+ base::FilePath destination = temp_dir_.path().AppendASCII(*it);
+ if (copy_gold) {
+ base::FilePath source = test_root_folder_.AppendASCII("gold.txt");
+ EXPECT_TRUE(base::CopyFile(source, destination));
+ }
+ result.push_back(destination);
+ }
+ return result;
+ }
+
void CheckStoredDirectoryMatches(const base::FilePath& filename) {
const Extension* extension = GetSingleLoadedExtension();
ASSERT_TRUE(extension);
@@ -222,6 +246,31 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
CheckStoredDirectoryMatches(test_file);
}
+IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenMultipleSuggested) {
+ base::FilePath test_file = TempFilePath("open_existing.txt", true);
+ ASSERT_FALSE(test_file.empty());
+ ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ chrome::DIR_USER_DOCUMENTS, test_file.DirName(), false));
+ FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest();
+ ASSERT_TRUE(RunPlatformAppTest(
+ "api_test/file_system/open_multiple_with_suggested_name"))
+ << message_;
+ CheckStoredDirectoryMatches(test_file);
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
+ FileSystemApiOpenMultipleExistingFilesTest) {
+ std::vector<std::string> names;
+ names.push_back("open_existing1.txt");
+ names.push_back("open_existing2.txt");
+ std::vector<base::FilePath> test_files = TempFilePaths(names, true);
+ ASSERT_EQ(2u, test_files.size());
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathsForTest(
+ &test_files);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_multiple_existing"))
+ << message_;
+}
+
IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
FileSystemApiInvalidChooseEntryTypeTest) {
base::FilePath test_file = TempFilePath("open_existing.txt", true);
@@ -272,6 +321,20 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
CheckStoredDirectoryMatches(test_file);
}
+IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
+ FileSystemApiOpenMultipleWritableExistingFilesTest) {
+ std::vector<std::string> names;
+ names.push_back("open_existing1.txt");
+ names.push_back("open_existing2.txt");
+ std::vector<base::FilePath> test_files = TempFilePaths(names, true);
+ ASSERT_EQ(2u, test_files.size());
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathsForTest(
+ &test_files);
+ ASSERT_TRUE(RunPlatformAppTest(
+ "api_test/file_system/open_multiple_writable_existing_with_write"))
+ << message_;
+}
+
IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiOpenCancelTest) {
FileSystemChooseEntryFunction::SkipPickerAndAlwaysCancelForTest();
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_cancel"))
@@ -326,6 +389,18 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
CheckStoredDirectoryMatches(test_file);
}
+IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveMultipleFilesTest) {
+ std::vector<std::string> names;
+ names.push_back("save1.txt");
+ names.push_back("save2.txt");
+ std::vector<base::FilePath> test_files = TempFilePaths(names, false);
+ ASSERT_EQ(2u, test_files.size());
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathsForTest(
+ &test_files);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_multiple"))
+ << message_;
+}
+
IN_PROC_BROWSER_TEST_F(FileSystemApiTest, FileSystemApiSaveCancelTest) {
FileSystemChooseEntryFunction::SkipPickerAndAlwaysCancelForTest();
ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_cancel"))
« no previous file with comments | « chrome/browser/extensions/api/file_system/file_system_api.cc ('k') | chrome/common/extensions/api/file_system.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698