| 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 "base/bind.h" | 5 #include "base/bind.h" |
| 6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
| 7 #include "base/files/file_util.h" | 7 #include "base/files/file_util.h" |
| 8 #include "base/files/scoped_temp_dir.h" | 8 #include "base/files/scoped_temp_dir.h" |
| 9 #include "base/path_service.h" | 9 #include "base/path_service.h" |
| 10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
| (...skipping 434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 445 << "Failed to initialize file system."; | 445 << "Failed to initialize file system."; |
| 446 } | 446 } |
| 447 | 447 |
| 448 // FileSystemExtensionApiTestBase override. | 448 // FileSystemExtensionApiTestBase override. |
| 449 void AddTestMountPoint() override { | 449 void AddTestMountPoint() override { |
| 450 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) | 450 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) |
| 451 ->RegisterFileSystem(kLocalMountPointName, | 451 ->RegisterFileSystem(kLocalMountPointName, |
| 452 storage::kFileSystemTypeNativeLocal, | 452 storage::kFileSystemTypeNativeLocal, |
| 453 storage::FileSystemMountOption(), | 453 storage::FileSystemMountOption(), |
| 454 mount_point_dir_)); | 454 mount_point_dir_)); |
| 455 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( | 455 VolumeManager::Get(browser()->profile()) |
| 456 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); | 456 ->AddVolumeInfoForTesting(mount_point_dir_, VOLUME_TYPE_TESTING, |
| 457 chromeos::DEVICE_TYPE_UNKNOWN, |
| 458 false /* read_only */); |
| 457 } | 459 } |
| 458 | 460 |
| 459 private: | 461 private: |
| 460 base::ScopedTempDir tmp_dir_; | 462 base::ScopedTempDir tmp_dir_; |
| 461 base::FilePath mount_point_dir_; | 463 base::FilePath mount_point_dir_; |
| 462 }; | 464 }; |
| 463 | 465 |
| 464 // Tests for restricted native local file systems. | 466 // Tests for restricted native local file systems. |
| 465 class RestrictedFileSystemExtensionApiTest | 467 class RestrictedFileSystemExtensionApiTest |
| 466 : public FileSystemExtensionApiTestBase { | 468 : public FileSystemExtensionApiTestBase { |
| 467 public: | 469 public: |
| 468 RestrictedFileSystemExtensionApiTest() {} | 470 RestrictedFileSystemExtensionApiTest() {} |
| 469 ~RestrictedFileSystemExtensionApiTest() override {} | 471 ~RestrictedFileSystemExtensionApiTest() override {} |
| 470 | 472 |
| 471 // FileSystemExtensionApiTestBase override. | 473 // FileSystemExtensionApiTestBase override. |
| 472 void InitTestFileSystem() override { | 474 void InitTestFileSystem() override { |
| 473 ASSERT_TRUE(InitializeLocalFileSystem( | 475 ASSERT_TRUE(InitializeLocalFileSystem( |
| 474 kRestrictedMountPointName, &tmp_dir_, &mount_point_dir_)) | 476 kRestrictedMountPointName, &tmp_dir_, &mount_point_dir_)) |
| 475 << "Failed to initialize file system."; | 477 << "Failed to initialize file system."; |
| 476 } | 478 } |
| 477 | 479 |
| 478 // FileSystemExtensionApiTestBase override. | 480 // FileSystemExtensionApiTestBase override. |
| 479 void AddTestMountPoint() override { | 481 void AddTestMountPoint() override { |
| 480 EXPECT_TRUE( | 482 EXPECT_TRUE( |
| 481 content::BrowserContext::GetMountPoints(browser()->profile()) | 483 content::BrowserContext::GetMountPoints(browser()->profile()) |
| 482 ->RegisterFileSystem(kRestrictedMountPointName, | 484 ->RegisterFileSystem(kRestrictedMountPointName, |
| 483 storage::kFileSystemTypeRestrictedNativeLocal, | 485 storage::kFileSystemTypeRestrictedNativeLocal, |
| 484 storage::FileSystemMountOption(), | 486 storage::FileSystemMountOption(), |
| 485 mount_point_dir_)); | 487 mount_point_dir_)); |
| 486 VolumeManager::Get(browser()->profile())->AddVolumeInfoForTesting( | 488 VolumeManager::Get(browser()->profile()) |
| 487 mount_point_dir_, VOLUME_TYPE_TESTING, chromeos::DEVICE_TYPE_UNKNOWN); | 489 ->AddVolumeInfoForTesting(mount_point_dir_, VOLUME_TYPE_TESTING, |
| 490 chromeos::DEVICE_TYPE_UNKNOWN, |
| 491 false /* read_only */); |
| 488 } | 492 } |
| 489 | 493 |
| 490 private: | 494 private: |
| 491 base::ScopedTempDir tmp_dir_; | 495 base::ScopedTempDir tmp_dir_; |
| 492 base::FilePath mount_point_dir_; | 496 base::FilePath mount_point_dir_; |
| 493 }; | 497 }; |
| 494 | 498 |
| 495 // Tests for a drive file system. | 499 // Tests for a drive file system. |
| 496 class DriveFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase { | 500 class DriveFileSystemExtensionApiTest : public FileSystemExtensionApiTestBase { |
| 497 public: | 501 public: |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 676 } | 680 } |
| 677 | 681 |
| 678 // FileSystemExtensionApiTestBase override. | 682 // FileSystemExtensionApiTestBase override. |
| 679 void AddTestMountPoint() override { | 683 void AddTestMountPoint() override { |
| 680 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) | 684 EXPECT_TRUE(content::BrowserContext::GetMountPoints(browser()->profile()) |
| 681 ->RegisterFileSystem(kLocalMountPointName, | 685 ->RegisterFileSystem(kLocalMountPointName, |
| 682 storage::kFileSystemTypeNativeLocal, | 686 storage::kFileSystemTypeNativeLocal, |
| 683 storage::FileSystemMountOption(), | 687 storage::FileSystemMountOption(), |
| 684 local_mount_point_dir_)); | 688 local_mount_point_dir_)); |
| 685 VolumeManager::Get(browser()->profile()) | 689 VolumeManager::Get(browser()->profile()) |
| 686 ->AddVolumeInfoForTesting(local_mount_point_dir_, | 690 ->AddVolumeInfoForTesting(local_mount_point_dir_, VOLUME_TYPE_TESTING, |
| 687 VOLUME_TYPE_TESTING, | 691 chromeos::DEVICE_TYPE_UNKNOWN, |
| 688 chromeos::DEVICE_TYPE_UNKNOWN); | 692 false /* read_only */); |
| 689 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); | 693 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); |
| 690 } | 694 } |
| 691 | 695 |
| 692 protected: | 696 protected: |
| 693 // DriveIntegrationService factory function for this test. | 697 // DriveIntegrationService factory function for this test. |
| 694 drive::DriveIntegrationService* CreateDriveIntegrationService( | 698 drive::DriveIntegrationService* CreateDriveIntegrationService( |
| 695 Profile* profile) { | 699 Profile* profile) { |
| 696 fake_drive_service_ = new drive::FakeDriveService; | 700 fake_drive_service_ = new drive::FakeDriveService; |
| 697 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); | 701 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); |
| 698 | 702 |
| (...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 850 AppFileHandlerMulti) { | 854 AppFileHandlerMulti) { |
| 851 EXPECT_TRUE( | 855 EXPECT_TRUE( |
| 852 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", | 856 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", |
| 853 FILE_PATH_LITERAL("manifest.json"), | 857 FILE_PATH_LITERAL("manifest.json"), |
| 854 "", | 858 "", |
| 855 FLAGS_NONE)) | 859 FLAGS_NONE)) |
| 856 << message_; | 860 << message_; |
| 857 } | 861 } |
| 858 } // namespace | 862 } // namespace |
| 859 } // namespace file_manager | 863 } // namespace file_manager |
| OLD | NEW |