Chromium Code Reviews| 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 105 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 116 | 116 |
| 117 // Sets up the initial file system state for native local and restricted native | 117 // Sets up the initial file system state for native local and restricted native |
| 118 // local file systems. The hierarchy is the same as for the drive file system. | 118 // local file systems. The hierarchy is the same as for the drive file system. |
| 119 // The directory is created at unique_temp_dir/|mount_point_name| path. | 119 // The directory is created at unique_temp_dir/|mount_point_name| path. |
| 120 bool InitializeLocalFileSystem(std::string mount_point_name, | 120 bool InitializeLocalFileSystem(std::string mount_point_name, |
| 121 base::ScopedTempDir* tmp_dir, | 121 base::ScopedTempDir* tmp_dir, |
| 122 base::FilePath* mount_point_dir) { | 122 base::FilePath* mount_point_dir) { |
| 123 if (!tmp_dir->CreateUniqueTempDir()) | 123 if (!tmp_dir->CreateUniqueTempDir()) |
| 124 return false; | 124 return false; |
| 125 | 125 |
| 126 *mount_point_dir = tmp_dir->path().AppendASCII(mount_point_name); | 126 *mount_point_dir = tmp_dir->GetPath().AppendASCII(mount_point_name); |
| 127 // Create the mount point. | 127 // Create the mount point. |
| 128 if (!base::CreateDirectory(*mount_point_dir)) | 128 if (!base::CreateDirectory(*mount_point_dir)) |
| 129 return false; | 129 return false; |
| 130 | 130 |
| 131 base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir"); | 131 base::FilePath test_dir = mount_point_dir->AppendASCII("test_dir"); |
| 132 if (!base::CreateDirectory(test_dir)) | 132 if (!base::CreateDirectory(test_dir)) |
| 133 return false; | 133 return false; |
| 134 | 134 |
| 135 base::FilePath test_subdir = test_dir.AppendASCII("empty_test_dir"); | 135 base::FilePath test_subdir = test_dir.AppendASCII("empty_test_dir"); |
| 136 if (!base::CreateDirectory(test_subdir)) | 136 if (!base::CreateDirectory(test_subdir)) |
| (...skipping 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 538 | 538 |
| 539 // DriveFileSystemExtensionApiTest doesn't expect that several user profiles | 539 // DriveFileSystemExtensionApiTest doesn't expect that several user profiles |
| 540 // could exist simultaneously. | 540 // could exist simultaneously. |
| 541 DCHECK(fake_drive_service_ == NULL); | 541 DCHECK(fake_drive_service_ == NULL); |
| 542 fake_drive_service_ = new drive::FakeDriveService; | 542 fake_drive_service_ = new drive::FakeDriveService; |
| 543 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); | 543 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); |
| 544 | 544 |
| 545 std::map<std::string, std::string> resource_ids; | 545 std::map<std::string, std::string> resource_ids; |
| 546 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids)); | 546 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids)); |
| 547 | 547 |
| 548 return new drive::DriveIntegrationService( | 548 return new drive::DriveIntegrationService(profile, NULL, |
|
achuithb
2016/09/13 20:55:19
replace with nullptr since you're here
vabr (Chromium)
2016/09/14 10:58:19
Done in https://codereview.chromium.org/2338793004
| |
| 549 profile, NULL, fake_drive_service_, "", test_cache_root_.path(), NULL); | 549 fake_drive_service_, "", |
| 550 test_cache_root_.GetPath(), NULL); | |
|
achuithb
2016/09/13 20:55:19
nullptr
vabr (Chromium)
2016/09/14 10:58:19
Done in https://codereview.chromium.org/2338793004
| |
| 550 } | 551 } |
| 551 | 552 |
| 552 base::ScopedTempDir test_cache_root_; | 553 base::ScopedTempDir test_cache_root_; |
| 553 drive::FakeDriveService* fake_drive_service_; | 554 drive::FakeDriveService* fake_drive_service_; |
| 554 DriveIntegrationServiceFactory::FactoryCallback | 555 DriveIntegrationServiceFactory::FactoryCallback |
| 555 create_drive_integration_service_; | 556 create_drive_integration_service_; |
| 556 std::unique_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> | 557 std::unique_ptr<DriveIntegrationServiceFactory::ScopedFactoryForTest> |
| 557 service_factory_for_test_; | 558 service_factory_for_test_; |
| 558 }; | 559 }; |
| 559 | 560 |
| 560 // Tests for Drive file systems in multi-profile setting. | 561 // Tests for Drive file systems in multi-profile setting. |
| 561 class MultiProfileDriveFileSystemExtensionApiTest : | 562 class MultiProfileDriveFileSystemExtensionApiTest : |
| 562 public FileSystemExtensionApiTestBase { | 563 public FileSystemExtensionApiTestBase { |
| 563 public: | 564 public: |
| 564 MultiProfileDriveFileSystemExtensionApiTest() : second_profile_(NULL) {} | 565 MultiProfileDriveFileSystemExtensionApiTest() : second_profile_(NULL) {} |
| 565 | 566 |
| 566 void SetUpOnMainThread() override { | 567 void SetUpOnMainThread() override { |
| 567 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | |
| 568 | |
| 569 base::FilePath user_data_directory; | 568 base::FilePath user_data_directory; |
| 570 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); | 569 PathService::Get(chrome::DIR_USER_DATA, &user_data_directory); |
| 571 user_manager::UserManager::Get()->UserLoggedIn( | 570 user_manager::UserManager::Get()->UserLoggedIn( |
| 572 AccountId::FromUserEmail(kSecondProfileAccount), kSecondProfileHash, | 571 AccountId::FromUserEmail(kSecondProfileAccount), kSecondProfileHash, |
| 573 false); | 572 false); |
| 574 // Set up the secondary profile. | 573 // Set up the secondary profile. |
| 575 base::FilePath profile_dir = | 574 base::FilePath profile_dir = |
| 576 user_data_directory.Append( | 575 user_data_directory.Append( |
| 577 chromeos::ProfileHelper::GetUserProfileDir( | 576 chromeos::ProfileHelper::GetUserProfileDir( |
| 578 kSecondProfileHash).BaseName()); | 577 kSecondProfileHash).BaseName()); |
| 579 second_profile_ = | 578 second_profile_ = |
| 580 g_browser_process->profile_manager()->GetProfile(profile_dir); | 579 g_browser_process->profile_manager()->GetProfile(profile_dir); |
| 581 | 580 |
| 582 FileSystemExtensionApiTestBase::SetUpOnMainThread(); | 581 FileSystemExtensionApiTestBase::SetUpOnMainThread(); |
| 583 } | 582 } |
| 584 | 583 |
| 585 void InitTestFileSystem() override { | 584 void InitTestFileSystem() override { |
| 585 ASSERT_TRUE(tmp_dir_.CreateUniqueTempDir()); | |
|
vabr (Chromium)
2016/09/12 19:40:37
I needed to move the CreateUniqueTempDir call from
achuithb
2016/09/13 20:55:19
Would've been nice to pull this into a separate CL
vabr (Chromium)
2016/09/14 10:58:19
Done: https://codereview.chromium.org/2338793004.
| |
| 586 | |
| 586 // This callback will get called during Profile creation. | 587 // This callback will get called during Profile creation. |
| 587 create_drive_integration_service_ = base::Bind( | 588 create_drive_integration_service_ = base::Bind( |
| 588 &MultiProfileDriveFileSystemExtensionApiTest:: | 589 &MultiProfileDriveFileSystemExtensionApiTest:: |
| 589 CreateDriveIntegrationService, | 590 CreateDriveIntegrationService, |
| 590 base::Unretained(this)); | 591 base::Unretained(this)); |
| 591 service_factory_for_test_.reset( | 592 service_factory_for_test_.reset( |
| 592 new DriveIntegrationServiceFactory::ScopedFactoryForTest( | 593 new DriveIntegrationServiceFactory::ScopedFactoryForTest( |
| 593 &create_drive_integration_service_)); | 594 &create_drive_integration_service_)); |
| 594 } | 595 } |
| 595 | 596 |
| 596 void AddTestMountPoint() override { | 597 void AddTestMountPoint() override { |
| 597 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); | 598 test_util::WaitUntilDriveMountPointIsAdded(browser()->profile()); |
| 598 test_util::WaitUntilDriveMountPointIsAdded(second_profile_); | 599 test_util::WaitUntilDriveMountPointIsAdded(second_profile_); |
| 599 } | 600 } |
| 600 | 601 |
| 601 protected: | 602 protected: |
| 602 // DriveIntegrationService factory function for this test. | 603 // DriveIntegrationService factory function for this test. |
| 603 drive::DriveIntegrationService* CreateDriveIntegrationService( | 604 drive::DriveIntegrationService* CreateDriveIntegrationService( |
| 604 Profile* profile) { | 605 Profile* profile) { |
| 605 base::FilePath cache_dir; | 606 base::FilePath cache_dir; |
| 606 base::CreateTemporaryDirInDir(tmp_dir_.path(), base::FilePath::StringType(), | 607 base::CreateTemporaryDirInDir(tmp_dir_.GetPath(), |
| 607 &cache_dir); | 608 base::FilePath::StringType(), &cache_dir); |
| 608 | 609 |
| 609 drive::FakeDriveService* const fake_drive_service = | 610 drive::FakeDriveService* const fake_drive_service = |
| 610 new drive::FakeDriveService; | 611 new drive::FakeDriveService; |
| 611 fake_drive_service->LoadAppListForDriveApi("drive/applist.json"); | 612 fake_drive_service->LoadAppListForDriveApi("drive/applist.json"); |
| 612 EXPECT_TRUE(InitializeDriveService(fake_drive_service, &resource_ids_)); | 613 EXPECT_TRUE(InitializeDriveService(fake_drive_service, &resource_ids_)); |
| 613 | 614 |
| 614 return new drive::DriveIntegrationService( | 615 return new drive::DriveIntegrationService( |
| 615 profile, NULL, fake_drive_service, std::string(), cache_dir, NULL); | 616 profile, NULL, fake_drive_service, std::string(), cache_dir, NULL); |
| 616 } | 617 } |
| 617 | 618 |
| (...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 700 protected: | 701 protected: |
| 701 // DriveIntegrationService factory function for this test. | 702 // DriveIntegrationService factory function for this test. |
| 702 drive::DriveIntegrationService* CreateDriveIntegrationService( | 703 drive::DriveIntegrationService* CreateDriveIntegrationService( |
| 703 Profile* profile) { | 704 Profile* profile) { |
| 704 fake_drive_service_ = new drive::FakeDriveService; | 705 fake_drive_service_ = new drive::FakeDriveService; |
| 705 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); | 706 fake_drive_service_->LoadAppListForDriveApi("drive/applist.json"); |
| 706 | 707 |
| 707 std::map<std::string, std::string> resource_ids; | 708 std::map<std::string, std::string> resource_ids; |
| 708 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids)); | 709 EXPECT_TRUE(InitializeDriveService(fake_drive_service_, &resource_ids)); |
| 709 | 710 |
| 710 return new drive::DriveIntegrationService(profile, | 711 return new drive::DriveIntegrationService(profile, NULL, |
|
achuithb
2016/09/13 20:55:19
nullptrs in this invocation
vabr (Chromium)
2016/09/14 10:58:19
Done in https://codereview.chromium.org/2338793004
| |
| 711 NULL, | 712 fake_drive_service_, "drive", |
| 712 fake_drive_service_, | 713 test_cache_root_.GetPath(), NULL); |
| 713 "drive", | |
| 714 test_cache_root_.path(), | |
| 715 NULL); | |
| 716 } | 714 } |
| 717 | 715 |
| 718 private: | 716 private: |
| 719 // For local volume. | 717 // For local volume. |
| 720 base::ScopedTempDir local_tmp_dir_; | 718 base::ScopedTempDir local_tmp_dir_; |
| 721 base::FilePath local_mount_point_dir_; | 719 base::FilePath local_mount_point_dir_; |
| 722 | 720 |
| 723 // For drive volume. | 721 // For drive volume. |
| 724 base::ScopedTempDir test_cache_root_; | 722 base::ScopedTempDir test_cache_root_; |
| 725 drive::FakeDriveService* fake_drive_service_; | 723 drive::FakeDriveService* fake_drive_service_; |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 858 AppFileHandlerMulti) { | 856 AppFileHandlerMulti) { |
| 859 EXPECT_TRUE( | 857 EXPECT_TRUE( |
| 860 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", | 858 RunFileSystemExtensionApiTest("file_browser/app_file_handler_multi", |
| 861 FILE_PATH_LITERAL("manifest.json"), | 859 FILE_PATH_LITERAL("manifest.json"), |
| 862 "", | 860 "", |
| 863 FLAGS_NONE)) | 861 FLAGS_NONE)) |
| 864 << message_; | 862 << message_; |
| 865 } | 863 } |
| 866 } // namespace | 864 } // namespace |
| 867 } // namespace file_manager | 865 } // namespace file_manager |
| OLD | NEW |