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

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..281920346fdec547165e5e820fed84145b225db3 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();
Matt Giuca 2013/07/25 08:31:09 Indentation?
Sam McNally 2013/07/26 03:58:04 Clang format likes it this way.
+ 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);
@@ -223,6 +247,19 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTest,
}
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);
ASSERT_FALSE(test_file.empty());
@@ -272,6 +309,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 +377,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"))

Powered by Google App Engine
This is Rietveld 408576698