summaryrefslogtreecommitdiffstats
path: root/chrome
diff options
context:
space:
mode:
authorkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 07:16:58 +0000
committerkinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-06-05 07:16:58 +0000
commit3e52f3bc6c96b2dbe4835812ebe38663683b8ee6 (patch)
tree8b62b25ef779a6172ff2980c68961695ac3ced23 /chrome
parent14c0bc4952624e1b5d02b945224745495a67f064 (diff)
downloadchromium_src-3e52f3bc6c96b2dbe4835812ebe38663683b8ee6.zip
chromium_src-3e52f3bc6c96b2dbe4835812ebe38663683b8ee6.tar.gz
chromium_src-3e52f3bc6c96b2dbe4835812ebe38663683b8ee6.tar.bz2
Add more test for chrome.filesystem Drive support.
This CL adds test cases for multiple-file selection in the open dialog and the save dialog (onto a new or existing file.) The test code JS code is 100% shared with tests for local files for checking the consistency. The test setup part introduces the stuff specific to Drive. BUG=223464 Review URL: https://codereview.chromium.org/315903002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@275034 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r--chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc72
-rw-r--r--chrome/test/data/extensions/api_test/file_system/save_existing_with_write/test_util.js4
2 files changed, 74 insertions, 2 deletions
diff --git a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
index 77dd68b..87257ef 100644
--- a/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
+++ b/chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/path_service.h"
#include "chrome/browser/apps/app_browsertest_util.h"
#include "chrome/browser/chromeos/drive/drive_integration_service.h"
#include "chrome/browser/chromeos/drive/file_system_interface.h"
@@ -10,6 +11,7 @@
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/browser/extensions/api/file_system/file_system_api.h"
#include "chrome/browser/extensions/component_loader.h"
+#include "chrome/common/chrome_paths.h"
#include "content/public/test/test_utils.h"
#include "google_apis/drive/drive_api_parser.h"
#include "google_apis/drive/test_util.h"
@@ -77,6 +79,9 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
void SetUpTestFileHierarchy() {
const std::string root = fake_drive_service_->GetRootResourceId();
ASSERT_TRUE(AddTestFile("open_existing.txt", "Can you see me?", root));
+ ASSERT_TRUE(AddTestFile("open_existing1.txt", "Can you see me?", root));
+ ASSERT_TRUE(AddTestFile("open_existing2.txt", "Can you see me?", root));
+ ASSERT_TRUE(AddTestFile("save_existing.txt", "Can you see me?", root));
const std::string subdir = AddTestDirectory("subdir", root);
ASSERT_FALSE(subdir.empty());
ASSERT_TRUE(AddTestFile("open_existing.txt", "Can you see me?", subdir));
@@ -136,6 +141,33 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
}
IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiOpenMultipleSuggested) {
+ base::FilePath test_file = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/open_existing.txt");
+ ASSERT_TRUE(PathService::OverrideAndCreateIfNeeded(
+ chrome::DIR_USER_DOCUMENTS, test_file.DirName(), true, false));
+ FileSystemChooseEntryFunction::SkipPickerAndSelectSuggestedPathForTest();
+ ASSERT_TRUE(RunPlatformAppTest(
+ "api_test/file_system/open_multiple_with_suggested_name"))
+ << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiOpenMultipleExistingFilesTest) {
+ base::FilePath test_file1 = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/open_existing1.txt");
+ base::FilePath test_file2 = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/open_existing2.txt");
+ std::vector<base::FilePath> test_files;
+ test_files.push_back(test_file1);
+ test_files.push_back(test_file2);
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathsForTest(
+ &test_files);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/open_multiple_existing"))
+ << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
FileSystemApiOpenDirectoryTest) {
base::FilePath test_directory =
drive::util::GetDriveMountPointPath(browser()->profile()).AppendASCII(
@@ -182,4 +214,44 @@ IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
<< message_;
}
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiSaveNewFileTest) {
+ base::FilePath test_file = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/save_new.txt");
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
+ &test_file);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_new"))
+ << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiSaveExistingFileTest) {
+ base::FilePath test_file = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/save_existing.txt");
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
+ &test_file);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_existing"))
+ << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiSaveNewFileWithWriteTest) {
+ base::FilePath test_file = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/save_new.txt");
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
+ &test_file);
+ ASSERT_TRUE(RunPlatformAppTest("api_test/file_system/save_new_with_write"))
+ << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(FileSystemApiTestForDrive,
+ FileSystemApiSaveExistingFileWithWriteTest) {
+ base::FilePath test_file = drive::util::GetDriveMountPointPath(
+ browser()->profile()).AppendASCII("root/save_existing.txt");
+ FileSystemChooseEntryFunction::SkipPickerAndAlwaysSelectPathForTest(
+ &test_file);
+ ASSERT_TRUE(RunPlatformAppTest(
+ "api_test/file_system/save_existing_with_write")) << message_;
+}
+
} // namespace extensions
diff --git a/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/test_util.js b/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/test_util.js
index c4845b2..0b59e16 100644
--- a/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/test_util.js
+++ b/chrome/test/data/extensions/api_test/file_system/save_existing_with_write/test_util.js
@@ -12,9 +12,9 @@ function checkEntry(entry, expectedName, isNew, shouldBeWritable) {
var reader = new FileReader();
reader.onloadend = chrome.test.callbackPass(function(e) {
if (isNew)
- chrome.test.assertEq(reader.result, "");
+ chrome.test.assertEq("", reader.result);
else
- chrome.test.assertEq(reader.result.indexOf("Can you see me?"), 0);
+ chrome.test.assertEq(0, reader.result.indexOf("Can you see me?"));
// Test that we can write to the file, or not, depending on
// |shouldBeWritable|.
entry.createWriter(function(fileWriter) {