| Index: chrome/browser/extensions/api/file_system/file_system_apitest_chromeos.cc
|
| 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 ecab8750f539b21cb4b2c0f54152555bdbbc5edf..c96373adcb7c1edeeffe304f41d201757239b9ca 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
|
| @@ -25,6 +25,7 @@
|
| #include "components/drive/service/fake_drive_service.h"
|
| #include "content/public/test/test_utils.h"
|
| #include "extensions/browser/event_router.h"
|
| +#include "google_apis/drive/base_requests.h"
|
| #include "google_apis/drive/drive_api_parser.h"
|
| #include "google_apis/drive/test_util.h"
|
| #include "storage/browser/fileapi/external_mount_points.h"
|
| @@ -45,6 +46,9 @@ const char kChildDirectory[] = "child-dir";
|
| // ID of a testing extension.
|
| const char kTestingExtensionId[] = "pkplfbidichfdicaijlchgnapepdginl";
|
|
|
| +void IgnoreDriveEntryResult(google_apis::DriveApiErrorCode error,
|
| + std::unique_ptr<google_apis::FileResource> entry) {}
|
| +
|
| } // namespace
|
|
|
| // Skips the user consent dialog for chrome.fileSystem.requestFileSystem() and
|
| @@ -103,10 +107,7 @@ class ScopedAddListenerObserver : public EventRouter::Observer {
|
| // the integrated Google Drive support.
|
| class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
|
| public:
|
| - FileSystemApiTestForDrive()
|
| - : fake_drive_service_(NULL),
|
| - integration_service_(NULL) {
|
| - }
|
| + FileSystemApiTestForDrive() {}
|
|
|
| // Sets up fake Drive service for tests (this has to be injected before the
|
| // real DriveIntegrationService instance is created.)
|
| @@ -148,59 +149,52 @@ class FileSystemApiTestForDrive : public PlatformAppBrowserTest {
|
| Profile* profile) {
|
| // Ignore signin profile.
|
| if (profile->GetPath() == chromeos::ProfileHelper::GetSigninProfileDir())
|
| - return NULL;
|
| + return nullptr;
|
|
|
| // FileSystemApiTestForDrive doesn't expect that several user profiles could
|
| // exist simultaneously.
|
| - DCHECK(fake_drive_service_ == NULL);
|
| + DCHECK(!fake_drive_service_);
|
| fake_drive_service_ = new drive::FakeDriveService;
|
| fake_drive_service_->LoadAppListForDriveApi("drive/applist.json");
|
|
|
| SetUpTestFileHierarchy();
|
|
|
| integration_service_ = new drive::DriveIntegrationService(
|
| - profile, NULL, fake_drive_service_, std::string(),
|
| - test_cache_root_.GetPath(), NULL);
|
| + profile, nullptr, fake_drive_service_, std::string(),
|
| + test_cache_root_.GetPath(), nullptr);
|
| return integration_service_;
|
| }
|
|
|
| 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));
|
| + AddTestFile("open_existing.txt", "Can you see me?", root);
|
| + AddTestFile("open_existing1.txt", "Can you see me?", root);
|
| + AddTestFile("open_existing2.txt", "Can you see me?", root);
|
| + AddTestFile("save_existing.txt", "Can you see me?", root);
|
| +
|
| + const char kSubdirResourceId[] = "subdir_resource_id";
|
| + AddTestDirectory(kSubdirResourceId, "subdir", root);
|
| + AddTestFile("open_existing.txt", "Can you see me?", kSubdirResourceId);
|
| }
|
|
|
| - bool AddTestFile(const std::string& title,
|
| + void AddTestFile(const std::string& title,
|
| const std::string& data,
|
| const std::string& parent_id) {
|
| - std::unique_ptr<google_apis::FileResource> entry;
|
| - google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
|
| - fake_drive_service_->AddNewFile(
|
| - "text/plain", data, parent_id, title, false,
|
| - google_apis::test_util::CreateCopyResultCallback(&error, &entry));
|
| - content::RunAllPendingInMessageLoop();
|
| - return error == google_apis::HTTP_CREATED && entry;
|
| + fake_drive_service_->AddNewFile("text/plain", data, parent_id, title, false,
|
| + base::Bind(&IgnoreDriveEntryResult));
|
| }
|
|
|
| - std::string AddTestDirectory(const std::string& title,
|
| - const std::string& parent_id) {
|
| - std::unique_ptr<google_apis::FileResource> entry;
|
| - google_apis::DriveApiErrorCode error = google_apis::DRIVE_OTHER_ERROR;
|
| - fake_drive_service_->AddNewDirectory(
|
| - parent_id, title, drive::AddNewDirectoryOptions(),
|
| - google_apis::test_util::CreateCopyResultCallback(&error, &entry));
|
| - content::RunAllPendingInMessageLoop();
|
| - return error == google_apis::HTTP_CREATED && entry ? entry->file_id() : "";
|
| + void AddTestDirectory(const std::string& resource_id,
|
| + const std::string& title,
|
| + const std::string& parent_id) {
|
| + fake_drive_service_->AddNewDirectoryWithResourceId(
|
| + resource_id, parent_id, title, drive::AddNewDirectoryOptions(),
|
| + base::Bind(&IgnoreDriveEntryResult));
|
| }
|
|
|
| base::ScopedTempDir test_cache_root_;
|
| - drive::FakeDriveService* fake_drive_service_;
|
| - drive::DriveIntegrationService* integration_service_;
|
| + drive::FakeDriveService* fake_drive_service_ = nullptr;
|
| + drive::DriveIntegrationService* integration_service_ = nullptr;
|
| drive::DriveIntegrationServiceFactory::FactoryCallback
|
| create_drive_integration_service_;
|
| std::unique_ptr<drive::DriveIntegrationServiceFactory::ScopedFactoryForTest>
|
|
|