#include "base/stl_util.h"
#include "base/strings/stringprintf.h"
#include "chrome/browser/chromeos/drive/test_util.h"
+#include "chrome/browser/drive/event_logger.h"
#include "chrome/browser/drive/fake_drive_service.h"
#include "chrome/common/pref_names.h"
#include "content/public/test/test_browser_thread_bundle.h"
fake_network_change_notifier_.reset(
new test_util::FakeNetworkChangeNotifier);
+ logger_.reset(new EventLogger);
+
fake_drive_service_.reset(new CancelTestableFakeDriveService);
fake_drive_service_->LoadResourceListForWapi(
"gdata/root_feed.json");
"drive/applist.json");
scheduler_.reset(new JobScheduler(pref_service_.get(),
+ logger_.get(),
fake_drive_service_.get(),
base::MessageLoopProxy::current().get()));
scheduler_->SetDisableThrottling(true);
scoped_ptr<TestingPrefServiceSimple> pref_service_;
scoped_ptr<test_util::FakeNetworkChangeNotifier>
fake_network_change_notifier_;
+ scoped_ptr<EventLogger> logger_;
scoped_ptr<CancelTestableFakeDriveService> fake_drive_service_;
scoped_ptr<JobScheduler> scheduler_;
};
fake_drive_service_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
"new directory",
+ DriveServiceInterface::AddNewDirectoryOptions(),
google_apis::test_util::CreateCopyResultCallback(
&error, &resource_entry));
base::RunLoop().RunUntilIdle();
scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(), // Root directory.
"New Directory",
+ DriveServiceInterface::AddNewDirectoryOptions(),
+ ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
}
TEST_F(JobSchedulerTest, PriorityHandling) {
- const base::FilePath kDummyFilePath(FILE_PATH_LITERAL("dummy"));
-
// Saturate the metadata job queue with uninteresting jobs to prevent
// following jobs from starting.
google_apis::GDataErrorCode error_dontcare = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry_dontcare;
for (int i = 0; i < GetMetadataQueueMaxJobCount(); ++i) {
- scheduler_->CreateFile(
- fake_drive_service_->GetRootResourceId(),
- kDummyFilePath,
- base::StringPrintf("uninteresting file %d", i),
- "text/plain",
+ std::string resource_id("file:2_file_resource_id");
+ scheduler_->GetResourceEntry(
+ resource_id,
ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error_dontcare,
&entry_dontcare));
std::string title_4("new file 4");
std::vector<std::string> titles;
- scheduler_->CreateFile(
+ scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
- kDummyFilePath,
title_1,
- "text/plain",
+ DriveServiceInterface::AddNewDirectoryOptions(),
ClientContext(USER_INITIATED),
base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
- scheduler_->CreateFile(
+ scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
- kDummyFilePath,
title_2,
- "text/plain",
+ DriveServiceInterface::AddNewDirectoryOptions(),
ClientContext(BACKGROUND),
base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
- scheduler_->CreateFile(
+ scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
- kDummyFilePath,
title_3,
- "text/plain",
+ DriveServiceInterface::AddNewDirectoryOptions(),
ClientContext(BACKGROUND),
base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
- scheduler_->CreateFile(
+ scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
- kDummyFilePath,
title_4,
- "text/plain",
+ DriveServiceInterface::AddNewDirectoryOptions(),
ClientContext(USER_INITIATED),
base::Bind(&CopyTitleFromGetResourceEntryCallback, &titles));
TEST_F(JobSchedulerTest, NoConnectionUserInitiated) {
ConnectToNone();
+ std::string resource_id("file:2_file_resource_id");
+
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry;
- scheduler_->CreateFile(
- fake_drive_service_->GetRootResourceId(),
- base::FilePath(FILE_PATH_LITERAL("dummy")),
- "title",
- "text/plain",
+ scheduler_->GetResourceEntry(
+ resource_id,
ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
google_apis::GDataErrorCode error = google_apis::GDATA_OTHER_ERROR;
scoped_ptr<google_apis::ResourceEntry> entry;
- scheduler_->CreateFile(
- fake_drive_service_->GetRootResourceId(),
- base::FilePath(FILE_PATH_LITERAL("dummy")),
- "title",
- "text/plain",
+ scheduler_->GetResourceEntry(
+ resource_id,
ClientContext(BACKGROUND),
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
base::RunLoop().RunUntilIdle();
EXPECT_EQ(google_apis::HTTP_SUCCESS, error);
ASSERT_TRUE(entry);
- EXPECT_EQ("title", entry->title());
}
TEST_F(JobSchedulerTest, DownloadFileCellularDisabled) {
scheduler_->AddNewDirectory(
fake_drive_service_->GetRootResourceId(),
"New Directory",
+ DriveServiceInterface::AddNewDirectoryOptions(),
+ ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error, &entry));
expected_types.insert(TYPE_GET_ABOUT_RESOURCE);
scheduler_->GetAboutResource(
path,
"dummy title",
"plain/plain",
+ DriveUploader::UploadNewFileOptions(),
ClientContext(BACKGROUND),
google_apis::test_util::CreateCopyResultCallback(&upload_error, &entry));
base::RunLoop().RunUntilIdle();
upload_path,
"dummy title 1",
"text/plain",
+ DriveUploader::UploadNewFileOptions(),
ClientContext(BACKGROUND),
google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
upload_path,
"dummy title 2",
"text/plain",
+ DriveUploader::UploadNewFileOptions(),
ClientContext(BACKGROUND),
google_apis::test_util::CreateCopyResultCallback(&error2, &entry));
upload_path,
"dummy title 1",
"text/plain",
+ DriveUploader::UploadNewFileOptions(),
ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error1, &entry));
upload_path,
"dummy title 2",
"text/plain",
+ DriveUploader::UploadNewFileOptions(),
ClientContext(USER_INITIATED),
google_apis::test_util::CreateCopyResultCallback(&error2, &entry));