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
3 // found in the LICENSE file.
6 #include "base/files/file_path.h"
7 #include "base/files/file_util.h"
8 #include "base/files/scoped_temp_dir.h"
9 #include "base/path_service.h"
10 #include "chrome/browser/browser_process.h"
11 #include "chrome/browser/chromeos/drive/drive_integration_service.h"
12 #include "chrome/browser/chromeos/file_manager/drive_test_util.h"
13 #include "chrome/browser/chromeos/file_manager/volume_manager.h"
14 #include "chrome/browser/chromeos/profiles/profile_helper.h"
15 #include "chrome/browser/drive/fake_drive_service.h"
16 #include "chrome/browser/extensions/extension_apitest.h"
17 #include "chrome/browser/profiles/profile.h"
18 #include "chrome/browser/profiles/profile_manager.h"
19 #include "chrome/browser/ui/browser.h"
20 #include "chrome/common/chrome_constants.h"
21 #include "chrome/common/chrome_paths.h"
22 #include "components/user_manager/user_manager.h"
23 #include "content/public/browser/browser_context.h"
24 #include "content/public/browser/notification_service.h"
25 #include "content/public/test/test_utils.h"
26 #include "extensions/browser/notification_types.h"
27 #include "extensions/test/result_catcher.h"
28 #include "google_apis/drive/drive_api_parser.h"
29 #include "google_apis/drive/test_util.h"
30 #include "google_apis/drive/time_util.h"
31 #include "storage/browser/fileapi/external_mount_points.h"
33 // Tests for access to external file systems (as defined in
34 // storage/common/fileapi/file_system_types.h) from extensions with
35 // fileManagerPrivate and fileBrowserHandler extension permissions.
36 // The tests cover following external file system types:
37 // - local (kFileSystemTypeLocalNative): a local file system on which files are
38 // accessed using native local path.
39 // - restricted (kFileSystemTypeRestrictedLocalNative): a *read-only* local file
40 // system which can only be accessed by extensions that have full access to
41 // external file systems (i.e. extensions with fileManagerPrivate permission).
42 // - drive (kFileSystemTypeDrive): a file system that provides access to Google
45 // The tests cover following scenarios:
46 // - Performing file system operations on external file systems from an
47 // app with fileManagerPrivate permission (i.e. Files.app).
48 // - Performing read/write operations from file handler extensions. These
49 // extensions need a file browser extension to give them permissions to access
50 // files. This also includes file handler extensions in filesystem API.
51 // - Observing directory changes from a file browser extension (using
52 // fileManagerPrivate API).
53 // - Doing searches on drive file system from file browser extension (using
54 // fileManagerPrivate API).
56 using drive::DriveIntegrationServiceFactory;
57 using extensions::Extension;
59 namespace file_manager {
62 // Root dirs for file systems expected by the test extensions.
63 // NOTE: Root dir for drive file system is set by Chrome's drive implementation,
64 // but the test will have to make sure the mount point is added before
65 // starting a test extension using WaitUntilDriveMountPointIsAdded().
66 const char kLocalMountPointName[] = "local";
67 const char kRestrictedMountPointName[] = "restricted";
69 // Default file content for the test files.
70 const char kTestFileContent[] = "This is some test content.";
72 // User account email and directory hash for secondary account for multi-profile
73 // sensitive test cases.
74 const char kSecondProfileAccount[] = "profile2@test.com";
75 const char kSecondProfileHash[] = "fileBrowserApiTestProfile2";
77 // Sets up the initial file system state for native local and restricted native
78 // local file systems. The hierarchy is the same as for the drive file system.
79 // The directory is created at unique_temp_dir/|mount_point_name| path.
80 bool InitializeLocalFileSystem(std::string mount_point_name,
81 base::ScopedTempDir* tmp_dir,
82 base::FilePath* mount_point_dir) {
83 if (!tmp_dir->CreateUniqueTempDir())
86 *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name);
87 // Create the mount point.
88 if (!base::CreateDirectory(*mount_point_dir))
91 base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir");
92 if (!base::CreateDirectory(test_dir))
95 base::FilePath test_subdir = test_dir.AppendASCII("empty_test_dir");
96 if (!base::CreateDirectory(test_subdir))
99 test_subdir = test_dir.AppendASCII("subdir");
100 if (!base::CreateDirectory(test_subdir))
103 base::FilePath test_file = test_dir.AppendASCII("test_file.xul");
104 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
107 test_file = test_dir.AppendASCII("test_file.xul.foo");
108 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
111 test_file = test_dir.AppendASCII("test_file.tiff");
112 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
115 test_file = test_dir.AppendASCII("test_file.tiff.foo");
116 if (!google_apis::test_util::WriteStringToFile(test_file, kTestFileContent))
119 test_file = test_dir.AppendASCII("empty_test_file.foo");
120 if (!google_apis::test_util::WriteStringToFile(test_file, ""))
126 scoped_ptr<google_apis::FileResource> UpdateDriveEntryTime(
127 drive::FakeDriveService* fake_drive_service,
128 const std::string& resource_id,
129 const std::string& last_modified,
130 const std::string& last_viewed_by_me) {
131 base::Time last_modified_time, last_viewed_by_me_time;
132 if (!google_apis::util::GetTimeFromString(last_modified,
133 &last_modified_time) ||
134 !google_apis::util::GetTimeFromString(last_viewed_by_me,
135 &last_viewed_by_me_time))
136 return scoped_ptr<google_apis::FileResource>();
138 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
139 scoped_ptr<google_apis::FileResource> entry;
140 fake_drive_service->UpdateResource(
142 std::string(), // parent_resource_id
143 std::string(), // title
145 last_viewed_by_me_time,
146 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
147 base::RunLoop().RunUntilIdle();
148 if (error != google_apis::HTTP_SUCCESS)
149 return scoped_ptr<google_apis::FileResource>();
154 scoped_ptr<google_apis::FileResource> AddFileToDriveService(
155 drive::FakeDriveService* fake_drive_service,
156 const std::string& mime_type,
157 const std::string& content,
158 const std::string& parent_resource_id,
159 const std::string& title,
160 const std::string& last_modified,
161 const std::string& last_viewed_by_me) {
162 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
163 scoped_ptr<google_apis::FileResource> entry;
164 fake_drive_service->AddNewFile(
169 false, // shared_with_me
170 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
171 base::RunLoop().RunUntilIdle();
172 if (error != google_apis::HTTP_CREATED)
173 return scoped_ptr<google_apis::FileResource>();
175 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
176 last_modified, last_viewed_by_me);
179 scoped_ptr<google_apis::FileResource> AddDirectoryToDriveService(
180 drive::FakeDriveService* fake_drive_service,
181 const std::string& parent_resource_id,
182 const std::string& title,
183 const std::string& last_modified,
184 const std::string& last_viewed_by_me) {
185 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
186 scoped_ptr<google_apis::FileResource> entry;
187 fake_drive_service->AddNewDirectory(
190 drive::DriveServiceInterface::AddNewDirectoryOptions(),
191 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
192 base::RunLoop().RunUntilIdle();
193 if (error != google_apis::HTTP_CREATED)
194 return scoped_ptr<google_apis::FileResource>();
196 return UpdateDriveEntryTime(fake_drive_service, entry->file_id(),
197 last_modified, last_viewed_by_me);
200 // Sets up the drive service state.
201 // The hierarchy is the same as for the local file system.
202 bool InitializeDriveService(
203 drive::FakeDriveService* fake_drive_service,
204 std::map<std::string, std::string>* out_resource_ids) {
205 scoped_ptr<google_apis::FileResource> entry;
207 entry = AddDirectoryToDriveService(fake_drive_service,
208 fake_drive_service->GetRootResourceId(),
210 "2012-01-02T00:00:00.000Z",
211 "2012-01-02T00:00:01.000Z");
214 (*out_resource_ids)[entry->title()] = entry->file_id();
216 entry = AddDirectoryToDriveService(fake_drive_service,
217 (*out_resource_ids)["test_dir"],
219 "2011-11-02T04:00:00.000Z",
220 "2011-11-02T04:00:00.000Z");
223 (*out_resource_ids)[entry->title()] = entry->file_id();
225 entry = AddDirectoryToDriveService(fake_drive_service,
226 (*out_resource_ids)["test_dir"],
228 "2011-04-01T18:34:08.234Z",
229 "2012-01-02T00:00:01.000Z");
232 (*out_resource_ids)[entry->title()] = entry->file_id();
234 entry = AddFileToDriveService(fake_drive_service,
235 "application/vnd.mozilla.xul+xml",
237 (*out_resource_ids)["test_dir"],
239 "2011-12-14T00:40:47.330Z",
240 "2012-01-02T00:00:00.000Z");
243 (*out_resource_ids)[entry->title()] = entry->file_id();
245 entry = AddFileToDriveService(fake_drive_service,
248 (*out_resource_ids)["test_dir"],
250 "2012-01-01T10:00:30.000Z",
251 "2012-01-01T00:00:00.000Z");
254 (*out_resource_ids)[entry->title()] = entry->file_id();
256 entry = AddFileToDriveService(fake_drive_service,
259 (*out_resource_ids)["test_dir"],
261 "2011-04-03T11:11:10.000Z",
262 "2012-01-02T00:00:00.000Z");
265 (*out_resource_ids)[entry->title()] = entry->file_id();
267 entry = AddFileToDriveService(fake_drive_service,
270 (*out_resource_ids)["test_dir"],
271 "test_file.tiff.foo",
272 "2011-12-14T00:40:47.330Z",
273 "2010-01-02T00:00:00.000Z");
276 (*out_resource_ids)[entry->title()] = entry->file_id();
278 entry = AddFileToDriveService(fake_drive_service,
281 (*out_resource_ids)["test_dir"],
282 "empty_test_file.foo",
283 "2011-12-14T00:40:47.330Z",
284 "2011-12-14T00:40:47.330Z");
287 (*out_resource_ids)[entry->title()] = entry->file_id();
292 // Helper class to wait for a background page to load or close again.
293 class BackgroundObserver {
296 : page_created_(extensions::NOTIFICATION_EXTENSION_BACKGROUND_PAGE_READY,
297 content::NotificationService::AllSources()),
298 page_closed_(extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED,
299 content::NotificationService::AllSources()) {}
301 void WaitUntilLoaded() {
302 page_created_.Wait();
305 void WaitUntilClosed() {
310 content::WindowedNotificationObserver page_created_;
311 content::WindowedNotificationObserver page_closed_;
314 // Base class for FileSystemExtensionApi tests.
315 class FileSystemExtensionApiTestBase : public ExtensionApiTest {
319 FLAGS_USE_FILE_HANDLER = 1 << 1,
320 FLAGS_LAZY_FILE_HANDLER = 1 << 2
323 FileSystemExtensionApiTestBase() {}
324 virtual ~FileSystemExtensionApiTestBase() {}
326 virtual void SetUp() OVERRIDE {
327 InitTestFileSystem();
328 ExtensionApiTest::SetUp();
331 virtual void SetUpOnMainThread() OVERRIDE {
333 ExtensionApiTest::SetUpOnMainThread();
336 // Runs a file system extension API test.
337 // It loads test component extension at |filebrowser_path| with manifest
338 // at |filebrowser_manifest|. The |filebrowser_manifest| should be a path
339 // relative to |filebrowser_path|. The method waits until the test extension
340 // sends test succeed or fail message. It returns true if the test succeeds.
341 // If |FLAGS_USE_FILE_HANDLER| flag is set, the file handler extension at path
342 // |filehandler_path| will be loaded before the file browser extension.
343 // If the flag FLAGS_LAZY_FILE_HANDLER is set, the file handler extension must
344 // not have persistent background page. The test will wait until the file
345 // handler's background page is closed after initial load before the file
346 // browser extension is loaded.
347 // If |RunFileSystemExtensionApiTest| fails, |message_| will contain a failure
349 bool RunFileSystemExtensionApiTest(
350 const std::string& filebrowser_path,
351 const base::FilePath::CharType* filebrowser_manifest,
352 const std::string& filehandler_path,
354 if (flags & FLAGS_USE_FILE_HANDLER) {
355 if (filehandler_path.empty()) {
356 message_ = "Missing file handler path.";
360 BackgroundObserver page_complete;
361 const Extension* file_handler =
362 LoadExtension(test_data_dir_.AppendASCII(filehandler_path));
366 if (flags & FLAGS_LAZY_FILE_HANDLER) {
367 page_complete.WaitUntilClosed();
369 page_complete.WaitUntilLoaded();
373 extensions::ResultCatcher catcher;
375 const Extension* file_browser = LoadExtensionAsComponentWithManifest(
376 test_data_dir_.AppendASCII(filebrowser_path),
377 filebrowser_manifest);
381 if (!catcher.GetNextResult()) {
382 message_ = catcher.message();
390 // Sets up initial test file system hierarchy.
391 virtual void InitTestFileSystem() = 0;
392 // Registers mount point used in the test.
393 virtual void AddTestMountPoint() = 0;
396 // Tests for a native local file system.
397 class LocalFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase {
399 LocalFileSystemExtensionApiTest() {}
400 virtual ~LocalFileSystemExtensionApiTest() {}
402 // FileSystemExtensionApiTestBase OVERRIDE.
403 virtual void InitTestFileSystem() OVERRIDE {
404 ASSERT_TRUE(InitializeLocalFileSystem(
405 kLocalMountPointName, &tmp_dir_, &mount_point_dir_))
406 << "Failed to initialize file system.";
409 // FileSystemExtensionApiTestBase OVERRIDE.
410 virtual void AddTestMountPoint() OVERRIDE {
411 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())
412 ->RegisterFileSystem(kLocalMountPointName,
413 storage::kFileSystemTypeNativeLocal,
414 storage::FileSystemMountOption(),
416 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting(
417 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN);
421 base::ScopedTempDir tmp_dir_;
422 base::FilePath mount_point_dir_;
425 // Tests for restricted native local file systems.
426 class RestrictedFileSystemExtensionApiTest
427 : public FileSystemExtensionApiTestBase {
429 RestrictedFileSystemExtensionApiTest() {}
430 virtual ~RestrictedFileSystemExtensionApiTest() {}
432 // FileSystemExtensionApiTestBase OVERRIDE.
433 virtual void InitTestFileSystem() OVERRIDE {
434 ASSERT_TRUE(InitializeLocalFileSystem(
435 kRestrictedMountPointName, &tmp_dir_, &mount_point_dir_))
436 << "Failed to initialize file system.";
439 // FileSystemExtensionApiTestBase OVERRIDE.
440 virtual void AddTestMountPoint() OVERRIDE {
442 content::BrowserContext::GetMountPoints(browser()->profile())
443 ->RegisterFileSystem(kRestrictedMountPointName,
444 storage::kFileSystemTypeRestrictedNativeLocal,
445 storage::FileSystemMountOption(),
447 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting(
448 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN);
452 base::ScopedTempDir tmp_dir_;
453 base::FilePath mount_point_dir_;
456 // Tests for a drive file system.
457 class DriveFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase {
459 DriveFileSystemExtensionApiTest() : fake_drive_service_(NULL) {}
460 virtual ~DriveFileSystemExtensionApiTest() {}
462 // FileSystemExtensionApiTestBase OVERRIDE.
463 virtual void InitTestFileSystem() OVERRIDE {
464 // Set up cache root to be used by DriveIntegrationService. This has to be
465 // done before the browser is created because the service instance is
466 // initialized by EventRouter.
467 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir());
469 // This callback will get called during Profile creation.
470 create_drive_integration_service_ = base::Bind(
471 &DriveFileSystemExtensionApiTest::CreateDriveIntegrationService,
472 base::Unretained(this));
473 service_factory_for_test_.reset(
474 new DriveIntegrationServiceFactory::ScopedFactoryForTest(
475 &create_drive_integration_service_));
478 // FileSystemExtensionApiTestBase OVERRIDE.
479 virtual void AddTestMountPoint() OVERRIDE {
480 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
484 // DriveIntegrationService factory function for this test.
485 drive::DriveIntegrationService* CreateDriveIntegrationService(
487 fake_drive_service_ = new drive::FakeDriveService;
488 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
490 std::map<std::string, std::string> resource_ids;
491 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids));
493 return new drive::DriveIntegrationService(
495 fake_drive_service_, "drive", test_cache_root_.path(), NULL);
498 base::ScopedTempDir test_cache_root_;
499 drive::FakeDriveService* fake_drive_service_;
500 DriveIntegrationServiceFactory::FactoryCallback
501 create_drive_integration_service_;
502 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
503 service_factory_for_test_;
506 // Tests for Drive file systems in multi-profile setting.
507 class MultiProfileDriveFileSystemExtensionApiTest :
508 public FileSystemExtensionApiTestBase {
510 MultiProfileDriveFileSystemExtensionApiTest() : second_profile(NULL) {}
512 virtual void SetUpOnMainThread() OVERRIDE {
513 base::FilePath user_data_directory;
514 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory);
515 user_manager::UserManager::Get()->UserLoggedIn(
516 kSecondProfileAccount, kSecondProfileHash, false);
517 // Set up the secondary profile.
518 base::FilePath profile_dir =
519 user_data_directory.Append(
520 chromeos::ProfileHelper::GetUserProfileDir(
521 kSecondProfileHash).BaseName());
523 g_browser_process->profile_manager()->GetProfile(profile_dir);
525 FileSystemExtensionApiTestBase::SetUpOnMainThread();
528 virtual void InitTestFileSystem() OVERRIDE {
529 // This callback will get called during Profile creation.
530 create_drive_integration_service_ = base::Bind(
531 &MultiProfileDriveFileSystemExtensionApiTest::
532 CreateDriveIntegrationService,
533 base::Unretained(this));
534 service_factory_for_test_.reset(
535 new DriveIntegrationServiceFactory::ScopedFactoryForTest(
536 &create_drive_integration_service_));
539 virtual void AddTestMountPoint() OVERRIDE {
540 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
541 test_util::WaitUntilDriveMountPointIsAdded(second_profile);
545 // DriveIntegrationService factory function for this test.
546 drive::DriveIntegrationService* CreateDriveIntegrationService(
548 base::FilePath cache_dir;
549 base::CreateNewTempDirectory(base::FilePath::StringType(), &cache_dir);
551 drive::FakeDriveService* const fake_drive_service =
552 new drive::FakeDriveService;
553 fake_drive_service->LoadAppListForDriveApi("drive/applist.json");
554 EXPECT_TRUE(InitializeDriveService(fake_drive_service, &resource_ids_));
556 return new drive::DriveIntegrationService(
557 profile, NULL, fake_drive_service, std::string(), cache_dir, NULL);
560 bool AddTestHostedDocuments() {
561 const char kResourceId[] = "unique-id-for-multiprofile-copy-test";
562 drive::FakeDriveService* const main_service =
563 static_cast<drive::FakeDriveService*>(
564 drive::util::GetDriveServiceByProfile(browser()->profile()));
565 drive::FakeDriveService* const sub_service =
566 static_cast<drive::FakeDriveService*>(
567 drive::util::GetDriveServiceByProfile(second_profile));
569 google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
570 scoped_ptr<google_apis::FileResource> entry;
572 // Place a hosted document under root/test_dir of the sub profile.
573 sub_service->AddNewFileWithResourceId(
575 "application/vnd.google-apps.document", "",
576 resource_ids_["test_dir"], "hosted_doc", true,
577 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
578 content::RunAllBlockingPoolTasksUntilIdle();
579 if (error != google_apis::HTTP_CREATED)
582 // Place the hosted document with no parent in the main profile, for
583 // simulating the situation that the document is shared to the main profile.
584 error = google_apis::GDATA_OTHER_ERROR;
585 main_service->AddNewFileWithResourceId(
587 "application/vnd.google-apps.document", "", "", "hosted_doc", true,
588 google_apis::test_util::CreateCopyResultCallback(&error, &entry));
589 content::RunAllBlockingPoolTasksUntilIdle();
590 return (error == google_apis::HTTP_CREATED);
593 DriveIntegrationServiceFactory::FactoryCallback
594 create_drive_integration_service_;
595 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
596 service_factory_for_test_;
597 Profile* second_profile;
598 std::map<std::string, std::string> resource_ids_;
601 class LocalAndDriveFileSystemExtensionApiTest
602 : public FileSystemExtensionApiTestBase {
604 LocalAndDriveFileSystemExtensionApiTest() {}
605 virtual ~LocalAndDriveFileSystemExtensionApiTest() {}
607 // FileSystemExtensionApiTestBase OVERRIDE.
608 virtual void InitTestFileSystem() OVERRIDE {
609 ASSERT_TRUE(InitializeLocalFileSystem(
610 kLocalMountPointName, &local_tmp_dir_, &local_mount_point_dir_))
611 << "Failed to initialize file system.";
613 // Set up cache root to be used by DriveIntegrationService. This has to be
614 // done before the browser is created because the service instance is
615 // initialized by EventRouter.
616 ASSERT_TRUE(test_cache_root_.CreateUniqueTempDir());
618 // This callback will get called during Profile creation.
619 create_drive_integration_service_ = base::Bind(
620 &LocalAndDriveFileSystemExtensionApiTest::CreateDriveIntegrationService,
621 base::Unretained(this));
622 service_factory_for_test_.reset(
623 new DriveIntegrationServiceFactory::ScopedFactoryForTest(
624 &create_drive_integration_service_));
627 // FileSystemExtensionApiTestBase OVERRIDE.
628 virtual void AddTestMountPoint() OVERRIDE {
629 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile())
630 ->RegisterFileSystem(kLocalMountPointName,
631 storage::kFileSystemTypeNativeLocal,
632 storage::FileSystemMountOption(),
633 local_mount_point_dir_));
634 VolumeManager::Get(browser()->profile())
635 ->AddVolumeInfoForTesting(local_mount_point_dir_,
637 chromeos::DEVICE_TYPE_UNKNOWN);
638 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile());
642 // DriveIntegrationService factory function for this test.
643 drive::DriveIntegrationService* CreateDriveIntegrationService(
645 fake_drive_service_ = new drive::FakeDriveService;
646 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
648 std::map<std::string, std::string> resource_ids;
649 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids));
651 return new drive::DriveIntegrationService(profile,
655 test_cache_root_.path(),
661 base::ScopedTempDir local_tmp_dir_;
662 base::FilePath local_mount_point_dir_;
665 base::ScopedTempDir test_cache_root_;
666 drive::FakeDriveService* fake_drive_service_;
667 DriveIntegrationServiceFactory::FactoryCallback
668 create_drive_integration_service_;
669 scoped_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest>
670 service_factory_for_test_;
674 // LocalFileSystemExtensionApiTests.
677 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileSystemOperations) {
678 EXPECT_TRUE(RunFileSystemExtensionApiTest(
679 "file_browser/filesystem_operations_test",
680 FILE_PATH_LITERAL("manifest.json"),
682 FLAGS_NONE)) << message_;
685 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileWatch) {
686 EXPECT_TRUE(RunFileSystemExtensionApiTest(
687 "file_browser/file_watcher_test",
688 FILE_PATH_LITERAL("manifest.json"),
690 FLAGS_NONE)) << message_;
693 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, FileBrowserHandlers) {
694 EXPECT_TRUE(RunFileSystemExtensionApiTest(
695 "file_browser/handler_test_runner",
696 FILE_PATH_LITERAL("manifest.json"),
697 "file_browser/file_browser_handler",
698 FLAGS_USE_FILE_HANDLER)) << message_;
701 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest,
702 FileBrowserHandlersLazy) {
703 EXPECT_TRUE(RunFileSystemExtensionApiTest(
704 "file_browser/handler_test_runner",
705 FILE_PATH_LITERAL("manifest.json"),
706 "file_browser/file_browser_handler_lazy",
707 FLAGS_USE_FILE_HANDLER | FLAGS_LAZY_FILE_HANDLER)) << message_;
710 IN_PROC_BROWSER_TEST_F(LocalFileSystemExtensionApiTest, AppFileHandler) {
711 EXPECT_TRUE(RunFileSystemExtensionApiTest(
712 "file_browser/handler_test_runner",
713 FILE_PATH_LITERAL("manifest.json"),
714 "file_browser/app_file_handler",
715 FLAGS_USE_FILE_HANDLER)) << message_;
719 // RestrictedFileSystemExtensionApiTests.
721 IN_PROC_BROWSER_TEST_F(RestrictedFileSystemExtensionApiTest,
722 FileSystemOperations) {
723 EXPECT_TRUE(RunFileSystemExtensionApiTest(
724 "file_browser/filesystem_operations_test",
725 FILE_PATH_LITERAL("manifest.json"),
727 FLAGS_NONE)) << message_;
731 // DriveFileSystemExtensionApiTests.
733 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileSystemOperations) {
734 EXPECT_TRUE(RunFileSystemExtensionApiTest(
735 "file_browser/filesystem_operations_test",
736 FILE_PATH_LITERAL("manifest.json"),
738 FLAGS_NONE)) << message_;
741 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileWatch) {
742 EXPECT_TRUE(RunFileSystemExtensionApiTest(
743 "file_browser/file_watcher_test",
744 FILE_PATH_LITERAL("manifest.json"),
746 FLAGS_NONE)) << message_;
749 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, FileBrowserHandlers) {
750 EXPECT_TRUE(RunFileSystemExtensionApiTest(
751 "file_browser/handler_test_runner",
752 FILE_PATH_LITERAL("manifest.json"),
753 "file_browser/file_browser_handler",
754 FLAGS_USE_FILE_HANDLER)) << message_;
757 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, Search) {
758 // Configure the drive service to return only one search result at a time
759 // to simulate paginated searches.
760 fake_drive_service_->set_default_max_results(1);
761 EXPECT_TRUE(RunFileSystemExtensionApiTest(
762 "file_browser/drive_search_test",
763 FILE_PATH_LITERAL("manifest.json"),
765 FLAGS_NONE)) << message_;
768 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest, AppFileHandler) {
769 EXPECT_TRUE(RunFileSystemExtensionApiTest(
770 "file_browser/handler_test_runner",
771 FILE_PATH_LITERAL("manifest.json"),
772 "file_browser/app_file_handler",
773 FLAGS_USE_FILE_HANDLER)) << message_;
776 IN_PROC_BROWSER_TEST_F(DriveFileSystemExtensionApiTest,
777 FileSystemFileOriginURL) {
778 EXPECT_TRUE(RunFileSystemExtensionApiTest(
779 "file_browser/filesystem_file_origin_url",
780 FILE_PATH_LITERAL("manifest.json"),
782 FLAGS_NONE)) << message_;
785 IN_PROC_BROWSER_TEST_F(MultiProfileDriveFileSystemExtensionApiTest,
787 ASSERT_TRUE(AddTestHostedDocuments());
788 EXPECT_TRUE(RunFileSystemExtensionApiTest(
789 "file_browser/multi_profile_copy",
790 FILE_PATH_LITERAL("manifest.json"),
792 FLAGS_NONE)) << message_;
796 // LocalAndDriveFileSystemExtensionApiTests.
798 IN_PROC_BROWSER_TEST_F(LocalAndDriveFileSystemExtensionApiTest,
799 AppFileHandlerMulti) {
801 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi",
802 FILE_PATH_LITERAL("manifest.json"),
808 } // namespace file_manager